<!-- The exported code uses Tailwind CSS. Install Tailwind CSS in your dev environment to ensure all styles work. -->
<template>
    <div class="min-h-screen bg-gray-50">
        <!-- 顶部导航栏 -->
        <Header />
        <!-- 左侧导航栏 -->
        <aside class="fixed left-0 top-16 bottom-0 w-64 bg-gray-800 text-white z-10 overflow-y-auto">
            <nav class="py-4">
                <div v-for="(menu, index) in mainMenus" :key="index" class="mb-1">
                    <div class="flex items-center px-6 py-3 cursor-pointer hover:bg-gray-700"
                        :class="{ 'bg-blue-700': menu.active }" @click="toggleMenu(index)">
                        <i :class="menu.icon + ' mr-3 w-5 text-center'"></i>
                        <span>{{ menu.name }}</span>
                        <i class="fas fa-chevron-down ml-auto text-xs transition-transform duration-200"
                            :class="{ 'transform rotate-180': menu.expanded }"></i>
                    </div>
                    <div v-if="menu.expanded" class="bg-gray-900">
                        <div v-for="(submenu, subIndex) in menu.subMenus" :key="subIndex"
                            class="flex items-center px-10 py-2 cursor-pointer hover:bg-gray-700"
                            :class="{ 'text-blue-400': submenu.active }" @click="selectSubmenu(index, subIndex)">
                            <a v-if="submenu.link" :href="submenu.link" data-readdy="true" class="text-sm w-full">{{
                                submenu.name }}</a>
                            <span v-else class="text-sm">{{ submenu.name }}</span>
                        </div>
                    </div>
                </div>
            </nav>
        </aside>
        <!-- 主内容区域 -->
        <main class="pt-16 pl-64">
            <div class="container mx-auto p-6">
                <!-- 面包屑导航 -->
                <div class="flex items-center text-sm mb-4 text-gray-500">
                    <span>首页</span>
                    <i class="fas fa-chevron-right mx-2 text-xs"></i>
                    <span>在线巡查</span>
                    <i class="fas fa-chevron-right mx-2 text-xs"></i>
                    <span class="text-blue-600">检索功能</span>
                </div>
                <!-- 检索统计概览 -->
                <div class="grid grid-cols-4 gap-4 mb-6">
                    <div class="bg-white rounded-lg shadow-sm p-4 flex items-center">
                        <div
                            class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-4">
                            <i class="fas fa-building text-xl"></i>
                        </div>
                        <div>
                            <div class="text-sm text-gray-500">企业总数</div>
                            <div class="text-2xl font-bold text-gray-900">186</div>
                            <div class="text-xs text-green-600 flex items-center">
                                <i class="fas fa-arrow-up mr-1"></i> 较上月增加 8 家
                            </div>
                        </div>
                    </div>
                    <div class="bg-white rounded-lg shadow-sm p-4 flex items-center">
                        <div
                            class="w-12 h-12 rounded-full bg-green-100 flex items-center justify-center text-green-600 mr-4">
                            <i class="fas fa-clipboard-check text-xl"></i>
                        </div>
                        <div>
                            <div class="text-sm text-gray-500">巡查记录</div>
                            <div class="text-2xl font-bold text-gray-900">1,256</div>
                            <div class="text-xs text-green-600 flex items-center">
                                <i class="fas fa-arrow-up mr-1"></i> 本月新增 78 条
                            </div>
                        </div>
                    </div>
                    <div class="bg-white rounded-lg shadow-sm p-4 flex items-center">
                        <div
                            class="w-12 h-12 rounded-full bg-yellow-100 flex items-center justify-center text-yellow-600 mr-4">
                            <i class="fas fa-exclamation-triangle text-xl"></i>
                        </div>
                        <div>
                            <div class="text-sm text-gray-500">问题隐患</div>
                            <div class="text-2xl font-bold text-gray-900">342</div>
                            <div class="text-xs text-red-600 flex items-center">
                                <i class="fas fa-arrow-up mr-1"></i> 较上月增加 12 项
                            </div>
                        </div>
                    </div>
                    <div class="bg-white rounded-lg shadow-sm p-4 flex items-center">
                        <div
                            class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600 mr-4">
                            <i class="fas fa-file-alt text-xl"></i>
                        </div>
                        <div>
                            <div class="text-sm text-gray-500">报告总数</div>
                            <div class="text-2xl font-bold text-gray-900">425</div>
                            <div class="text-xs text-gray-600 flex items-center">
                                <i class="fas fa-check mr-1"></i> 覆盖率 92.5%
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 检索条件区域 -->
                <div class="bg-white rounded-lg shadow-sm p-6 mb-6">
                    <div class="flex justify-between items-center mb-4">
                        <h2 class="font-bold text-lg text-gray-800">智能检索</h2>
                        <div class="flex space-x-3">
                            <button
                                class="px-4 py-2 bg-gray-100 text-gray-700 rounded flex items-center !rounded-button whitespace-nowrap cursor-pointer"
                                @click="toggleAdvancedSearch">
                                <i class="fas fa-sliders-h mr-2"></i> {{ showAdvancedSearch ? '收起高级搜索' : '展开高级搜索' }}
                            </button>
                            <button
                                class="px-4 py-2 bg-blue-600 text-white rounded flex items-center !rounded-button whitespace-nowrap cursor-pointer"
                                @click="performSearch" :disabled="searchLoading">
                                <i :class="['fas', searchLoading ? 'fa-spinner fa-spin' : 'fa-search', 'mr-2']"></i>
                                {{ searchLoading ? '搜索中...' : '检索' }}
                            </button>
                        </div>
                    </div>
                    <!-- 基础搜索条件 -->
                    <div class="grid grid-cols-4 gap-4 mb-4">
                        <!-- 企业名称 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">企业名称</label>
                            <div class="relative">
                                <input v-model="searchParams.companyName" type="text" placeholder="请输入企业名称"
                                    class="w-full bg-gray-100 border-none rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
                                <i
                                    class="fas fa-search absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
                            </div>
                        </div>
                        <!-- 巡查类型 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">巡查类型</label>
                            <div class="relative">
                                <div @click="toggleDropdown('inspectionType')"
                                    class="w-full flex items-center justify-between bg-gray-100 text-gray-700 px-3 py-2 rounded text-sm cursor-pointer">
                                    <span>{{ searchParams.inspectionType || '全部类型' }}</span>
                                    <i class="fas fa-chevron-down text-xs"></i>
                                </div>
                                <div v-if="activeDropdown === 'inspectionType'"
                                    class="absolute z-10 mt-1 w-full bg-white rounded-md shadow-lg py-1 text-sm">
                                    <div @click="selectDropdownItem('inspectionType', '全部类型')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">全部类型</div>
                                    <div @click="selectDropdownItem('inspectionType', '常规巡查')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">常规巡查</div>
                                    <div @click="selectDropdownItem('inspectionType', '专项巡查')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">专项巡查</div>
                                    <div @click="selectDropdownItem('inspectionType', '应急巡查')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">应急巡查</div>
                                    <div @click="selectDropdownItem('inspectionType', '复查')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">复查</div>
                                </div>
                            </div>
                        </div>
                        <!-- 巡查结果 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">巡查结果</label>
                            <div class="relative">
                                <div @click="toggleDropdown('inspectionResult')"
                                    class="w-full flex items-center justify-between bg-gray-100 text-gray-700 px-3 py-2 rounded text-sm cursor-pointer">
                                    <span>{{ searchParams.inspectionResult || '全部结果' }}</span>
                                    <i class="fas fa-chevron-down text-xs"></i>
                                </div>
                                <div v-if="activeDropdown === 'inspectionResult'"
                                    class="absolute z-10 mt-1 w-full bg-white rounded-md shadow-lg py-1 text-sm">
                                    <div @click="selectDropdownItem('inspectionResult', '全部结果')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">全部结果</div>
                                    <div @click="selectDropdownItem('inspectionResult', '合格')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">合格</div>
                                    <div @click="selectDropdownItem('inspectionResult', '不合格')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">不合格</div>
                                    <div @click="selectDropdownItem('inspectionResult', '整改中')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">整改中</div>
                                </div>
                            </div>
                        </div>
                        <!-- 时间范围 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">时间范围</label>
                            <div class="relative">
                                <div @click="toggleDropdown('timeRange')"
                                    class="w-full flex items-center justify-between bg-gray-100 text-gray-700 px-3 py-2 rounded text-sm cursor-pointer">
                                    <span>{{ searchParams.timeRange || '全部时间' }}</span>
                                    <i class="fas fa-calendar-alt text-xs"></i>
                                </div>
                                <div v-if="activeDropdown === 'timeRange'"
                                    class="absolute z-10 mt-1 w-full bg-white rounded-md shadow-lg py-1 text-sm">
                                    <div @click="selectDropdownItem('timeRange', '全部时间')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">全部时间</div>
                                    <div @click="selectDropdownItem('timeRange', '今日')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">今日</div>
                                    <div @click="selectDropdownItem('timeRange', '本周')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">本周</div>
                                    <div @click="selectDropdownItem('timeRange', '本月')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">本月</div>
                                    <div @click="selectDropdownItem('timeRange', '近 30 天')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">近 30 天</div>
                                    <div @click="selectDropdownItem('timeRange', '近 90 天')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">近 90 天</div>
                                    <div @click="selectDropdownItem('timeRange', '自定义')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">自定义</div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 高级搜索条件 -->
                    <div v-if="showAdvancedSearch" class="grid grid-cols-4 gap-4 mt-4 pt-4 border-t border-gray-200">
                        <!-- 巡查人员 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">巡查人员</label>
                            <div class="relative">
                                <input v-model="searchParams.inspector" type="text" placeholder="请输入巡查人员"
                                    class="w-full bg-gray-100 border-none rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
                            </div>
                        </div>
                        <!-- 所属区域 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">所属区域</label>
                            <div class="relative">
                                <div @click="toggleDropdown('region')"
                                    class="w-full flex items-center justify-between bg-gray-100 text-gray-700 px-3 py-2 rounded text-sm cursor-pointer">
                                    <span>{{ searchParams.region || '全部区域' }}</span>
                                    <i class="fas fa-chevron-down text-xs"></i>
                                </div>
                                <div v-if="activeDropdown === 'region'"
                                    class="absolute z-10 mt-1 w-full bg-white rounded-md shadow-lg py-1 text-sm">
                                    <div @click="selectDropdownItem('region', '全部区域')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">全部区域</div>
                                    <div @click="selectDropdownItem('region', '华北地区')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">华北地区</div>
                                    <div @click="selectDropdownItem('region', '华东地区')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">华东地区</div>
                                    <div @click="selectDropdownItem('region', '华南地区')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">华南地区</div>
                                    <div @click="selectDropdownItem('region', '华中地区')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">华中地区</div>
                                    <div @click="selectDropdownItem('region', '西北地区')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">西北地区</div>
                                    <div @click="selectDropdownItem('region', '西南地区')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">西南地区</div>
                                    <div @click="selectDropdownItem('region', '东北地区')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">东北地区</div>
                                </div>
                            </div>
                        </div>
                        <!-- 企业规模 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">企业规模</label>
                            <div class="relative">
                                <div @click="toggleDropdown('companySize')"
                                    class="w-full flex items-center justify-between bg-gray-100 text-gray-700 px-3 py-2 rounded text-sm cursor-pointer">
                                    <span>{{ searchParams.companySize || '全部规模' }}</span>
                                    <i class="fas fa-chevron-down text-xs"></i>
                                </div>
                                <div v-if="activeDropdown === 'companySize'"
                                    class="absolute z-10 mt-1 w-full bg-white rounded-md shadow-lg py-1 text-sm">
                                    <div @click="selectDropdownItem('companySize', '全部规模')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">全部规模</div>
                                    <div @click="selectDropdownItem('companySize', '大型企业')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">大型企业</div>
                                    <div @click="selectDropdownItem('companySize', '中型企业')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">中型企业</div>
                                    <div @click="selectDropdownItem('companySize', '小型企业')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">小型企业</div>
                                </div>
                            </div>
                        </div>
                        <!-- 问题类型 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">问题类型</label>
                            <div class="relative">
                                <div @click="toggleDropdown('issueType')"
                                    class="w-full flex items-center justify-between bg-gray-100 text-gray-700 px-3 py-2 rounded text-sm cursor-pointer">
                                    <span>{{ searchParams.issueType || '全部类型' }}</span>
                                    <i class="fas fa-chevron-down text-xs"></i>
                                </div>
                                <div v-if="activeDropdown === 'issueType'"
                                    class="absolute z-10 mt-1 w-full bg-white rounded-md shadow-lg py-1 text-sm">
                                    <div @click="selectDropdownItem('issueType', '全部类型')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">全部类型</div>
                                    <div @click="selectDropdownItem('issueType', '设备隐患')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">设备隐患</div>
                                    <div @click="selectDropdownItem('issueType', '工艺隐患')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">工艺隐患</div>
                                    <div @click="selectDropdownItem('issueType', '消防隐患')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">消防隐患</div>
                                    <div @click="selectDropdownItem('issueType', '电气隐患')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">电气隐患</div>
                                    <div @click="selectDropdownItem('issueType', '特种设备')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">特种设备</div>
                                    <div @click="selectDropdownItem('issueType', '其他隐患')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">其他隐患</div>
                                </div>
                            </div>
                        </div>
                        <!-- 风险等级 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">风险等级</label>
                            <div class="relative">
                                <div @click="toggleDropdown('riskLevel')"
                                    class="w-full flex items-center justify-between bg-gray-100 text-gray-700 px-3 py-2 rounded text-sm cursor-pointer">
                                    <span>{{ searchParams.riskLevel || '全部等级' }}</span>
                                    <i class="fas fa-chevron-down text-xs"></i>
                                </div>
                                <div v-if="activeDropdown === 'riskLevel'"
                                    class="absolute z-10 mt-1 w-full bg-white rounded-md shadow-lg py-1 text-sm">
                                    <div @click="selectDropdownItem('riskLevel', '全部等级')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">全部等级</div>
                                    <div @click="selectDropdownItem('riskLevel', '高风险')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">高风险</div>
                                    <div @click="selectDropdownItem('riskLevel', '中风险')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">中风险</div>
                                    <div @click="selectDropdownItem('riskLevel', '低风险')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">低风险</div>
                                </div>
                            </div>
                        </div>
                        <!-- 整改状态 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">整改状态</label>
                            <div class="relative">
                                <div @click="toggleDropdown('fixStatus')"
                                    class="w-full flex items-center justify-between bg-gray-100 text-gray-700 px-3 py-2 rounded text-sm cursor-pointer">
                                    <span>{{ searchParams.fixStatus || '全部状态' }}</span>
                                    <i class="fas fa-chevron-down text-xs"></i>
                                </div>
                                <div v-if="activeDropdown === 'fixStatus'"
                                    class="absolute z-10 mt-1 w-full bg-white rounded-md shadow-lg py-1 text-sm">
                                    <div @click="selectDropdownItem('fixStatus', '全部状态')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">全部状态</div>
                                    <div @click="selectDropdownItem('fixStatus', '已整改')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">已整改</div>
                                    <div @click="selectDropdownItem('fixStatus', '整改中')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">整改中</div>
                                    <div @click="selectDropdownItem('fixStatus', '未整改')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">未整改</div>
                                    <div @click="selectDropdownItem('fixStatus', '无需整改')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">无需整改</div>
                                </div>
                            </div>
                        </div>
                        <!-- 报告状态 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">报告状态</label>
                            <div class="relative">
                                <div @click="toggleDropdown('reportStatus')"
                                    class="w-full flex items-center justify-between bg-gray-100 text-gray-700 px-3 py-2 rounded text-sm cursor-pointer">
                                    <span>{{ searchParams.reportStatus || '全部状态' }}</span>
                                    <i class="fas fa-chevron-down text-xs"></i>
                                </div>
                                <div v-if="activeDropdown === 'reportStatus'"
                                    class="absolute z-10 mt-1 w-full bg-white rounded-md shadow-lg py-1 text-sm">
                                    <div @click="selectDropdownItem('reportStatus', '全部状态')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">全部状态</div>
                                    <div @click="selectDropdownItem('reportStatus', '已生成')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">已生成</div>
                                    <div @click="selectDropdownItem('reportStatus', '未生成')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">未生成</div>
                                    <div @click="selectDropdownItem('reportStatus', '已审核')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">已审核</div>
                                    <div @click="selectDropdownItem('reportStatus', '待审核')"
                                        class="px-3 py-2 hover:bg-gray-100 cursor-pointer">待审核</div>
                                </div>
                            </div>
                        </div>
                        <!-- 关键词 -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-1">关键词</label>
                            <div class="relative">
                                <input v-model="searchParams.keywords" type="text" placeholder="请输入关键词"
                                    class="w-full bg-gray-100 border-none rounded px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
                            </div>
                        </div>
                    </div>
                    <!-- 已选条件标签 -->
                    <div v-if="hasActiveFilters" class="mt-4 pt-4 border-t border-gray-200">
                        <div class="flex items-center flex-wrap gap-2">
                            <span class="text-sm text-gray-500">已选条件：</span>
                            <div v-for="(value, key) in activeFilters" :key="key"
                                class="bg-blue-100 text-blue-800 rounded-full px-3 py-1 text-xs flex items-center">
                                {{ getFilterLabel(key) }}: {{ value }}
                                <i @click="removeFilter(key)" class="fas fa-times-circle ml-1 cursor-pointer"></i>
                            </div>
                            <button @click="clearAllFilters"
                                class="text-blue-600 text-xs ml-2 !rounded-button whitespace-nowrap cursor-pointer">清空全部</button>
                        </div>
                    </div>
                </div>
                <!-- 检索结果统计分析 -->
                <div class="grid grid-cols-3 gap-6 mb-6">
                    <!-- 巡查类型分布 -->
                    <div class="bg-white rounded-lg shadow-sm p-4">
                        <h3 class="font-bold text-base text-gray-800 mb-3">巡查类型分布</h3>
                        <div id="inspectionTypeChart" class="h-64" ref="inspectionTypeChart"></div>
                    </div>
                    <!-- 巡查结果分布 -->
                    <div class="bg-white rounded-lg shadow-sm p-4">
                        <h3 class="font-bold text-base text-gray-800 mb-3">巡查结果分布</h3>
                        <div id="inspectionResultChart" class="h-64" ref="inspectionResultChart"></div>
                    </div>
                    <!-- 巡查趋势 -->
                    <div class="bg-white rounded-lg shadow-sm p-4">
                        <h3 class="font-bold text-base text-gray-800 mb-3">巡查趋势</h3>
                        <div id="inspectionTrendChart" class="h-64" ref="inspectionTrendChart"></div>
                    </div>
                </div>
                <!-- 检索结果列表 -->
                <div class="bg-white rounded-lg shadow-sm p-6 mb-6">
                    <div class="flex justify-between items-center mb-4">
                        <h2 class="font-bold text-lg text-gray-800">检索结果 <span class="text-blue-600">(共 {{ searchResults.length }} 条)</span>
                        </h2>
                        <div class="flex space-x-3">
                            <button @click="showFilterModal = true"
                                class="px-4 py-2 bg-gray-100 text-gray-700 rounded flex items-center !rounded-button whitespace-nowrap cursor-pointer hover:bg-gray-200">
                                <i class="fas fa-filter mr-2"></i> 筛选
                            </button>
                            <button @click="showSortModal = true"
                                class="px-4 py-2 bg-gray-100 text-gray-700 rounded flex items-center !rounded-button whitespace-nowrap cursor-pointer hover:bg-gray-200">
                                <i class="fas fa-sort mr-2"></i> 排序
                            </button>
                            <button
                                @click="exportSearchResults"
                                class="px-4 py-2 bg-green-600 text-white rounded flex items-center !rounded-button whitespace-nowrap cursor-pointer hover:bg-green-700">
                                <i class="fas fa-file-export mr-2"></i> 导出结果
                            </button>
                        </div>
                    </div>
                    <!-- 结果标签页 -->
                    <div class="border-b border-gray-200 mb-4">
                        <div class="flex space-x-6">
                            <button v-for="(tab, index) in resultTabs" :key="index"
                                class="px-4 py-2 text-sm font-medium border-b-2 -mb-px !rounded-button whitespace-nowrap cursor-pointer"
                                :class="tab.active ? 'text-blue-600 border-blue-600' : 'text-gray-500 border-transparent hover:text-gray-700 hover:border-gray-300'"
                                @click="setActiveResultTab(index)">
                                {{ tab.name }} ({{ tab.count }})
                            </button>
                        </div>
                    </div>
                    <!-- 结果列表 -->
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead>
                                <tr>
                                    <th
                                        class="px-4 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        记录编号</th>
                                    <th
                                        class="px-4 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        企业名称</th>
                                    <th
                                        class="px-4 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        巡查类型</th>
                                    <th
                                        class="px-4 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        巡查人员</th>
                                    <th
                                        class="px-4 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        巡查时间</th>
                                    <th
                                        class="px-4 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        巡查结果</th>
                                    <th
                                        class="px-4 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        问题数量</th>
                                    <th
                                        class="px-4 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        报告状态</th>
                                    <th
                                        class="px-4 py-3 bg-gray-50 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                        操作</th>
                                </tr>
                            </thead>
                            <tbody class="bg-white divide-y divide-gray-200">
                                <tr v-for="(record, index) in paginatedResults" :key="index" class="hover:bg-gray-50">
                                    <td class="px-4 py-3">
                                        <div class="text-sm font-medium text-gray-900">{{ record.id }}</div>
                                    </td>
                                    <td class="px-4 py-3">
                                        <div class="text-sm text-gray-900">{{ record.company }}</div>
                                    </td>
                                    <td class="px-4 py-3">
                                        <div class="text-sm text-gray-900">{{ record.type }}</div>
                                    </td>
                                    <td class="px-4 py-3">
                                        <div class="text-sm text-gray-900">{{ record.inspector }}</div>
                                    </td>
                                    <td class="px-4 py-3">
                                        <div class="text-sm text-gray-900">{{ record.date }}</div>
                                    </td>
                                    <td class="px-4 py-3">
                                        <span class="px-2 py-1 inline-flex text-xs leading-5 font-semibold rounded-full"
                                            :class="record.resultClass">
                                            {{ record.result }}
                                        </span>
                                    </td>
                                    <td class="px-4 py-3">
                                        <div class="text-sm text-gray-900">{{ record.issueCount }}</div>
                                    </td>
                                    <td class="px-4 py-3">
                                        <span class="px-2 py-1 inline-flex text-xs leading-5 font-semibold rounded-full"
                                            :class="record.reportStatusClass">
                                            {{ record.reportStatus }}
                                        </span>
                                    </td>
                                    <td class="px-4 py-3 whitespace-nowrap text-sm font-medium">
                                        <div class="flex space-x-2">
                                            <button
                                                class="text-blue-600 hover:text-blue-800 !rounded-button whitespace-nowrap cursor-pointer"
                                                @click="showRecordDetail(record)">详情</button>
                                            <button
                                                class="text-gray-600 hover:text-gray-800 !rounded-button whitespace-nowrap cursor-pointer"
                                                @click="viewReport(record)">报告</button>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <!-- 分页 -->
                    <div class="flex justify-between items-center mt-4">
                        <div class="text-sm text-gray-500">
                            显示 {{ paginationInfo.start }} 至 {{ paginationInfo.end }} 条，共 {{ paginationInfo.total }} 条
                        </div>
                        <div class="flex space-x-1">
                            <button
                                @click="goToPage(currentPage - 1)"
                                :disabled="currentPage === 1"
                                :class="[
                                    'px-3 py-1 rounded !rounded-button whitespace-nowrap',
                                    currentPage === 1 
                                        ? 'bg-gray-100 text-gray-400 cursor-not-allowed' 
                                        : 'bg-gray-100 text-gray-600 cursor-pointer hover:bg-gray-200'
                                ]">
                                上一页
                            </button>
                            
                            <!-- 显示第一页 -->
                            <button
                                v-if="visiblePageNumbers[0] > 1"
                                @click="goToPage(1)"
                                class="px-3 py-1 bg-gray-100 text-gray-600 rounded !rounded-button whitespace-nowrap cursor-pointer hover:bg-gray-200">
                                1
                            </button>
                            
                            <!-- 显示省略号 -->
                            <span
                                v-if="visiblePageNumbers[0] > 2"
                                class="px-3 py-1 text-gray-400">
                                ...
                            </span>
                            
                            <!-- 显示页码 -->
                            <button
                                v-for="page in visiblePageNumbers"
                                :key="page"
                                @click="goToPage(page)"
                                :class="[
                                    'px-3 py-1 rounded !rounded-button whitespace-nowrap cursor-pointer',
                                    page === currentPage 
                                        ? 'bg-blue-600 text-white' 
                                        : 'bg-gray-100 text-gray-600 hover:bg-gray-200'
                                ]">
                                {{ page }}
                            </button>
                            
                            <!-- 显示省略号 -->
                            <span
                                v-if="visiblePageNumbers[visiblePageNumbers.length - 1] < totalPages - 1"
                                class="px-3 py-1 text-gray-400">
                                ...
                            </span>
                            
                            <!-- 显示最后一页 -->
                            <button
                                v-if="visiblePageNumbers[visiblePageNumbers.length - 1] < totalPages"
                                @click="goToPage(totalPages)"
                                class="px-3 py-1 bg-gray-100 text-gray-600 rounded !rounded-button whitespace-nowrap cursor-pointer hover:bg-gray-200">
                                {{ totalPages }}
                            </button>
                            
                            <button
                                @click="goToPage(currentPage + 1)"
                                :disabled="currentPage === totalPages"
                                :class="[
                                    'px-3 py-1 rounded !rounded-button whitespace-nowrap',
                                    currentPage === totalPages 
                                        ? 'bg-gray-100 text-gray-400 cursor-not-allowed' 
                                        : 'bg-gray-100 text-gray-600 cursor-pointer hover:bg-gray-200'
                                ]">
                                下一页
                            </button>
                        </div>
                    </div>
                </div>
                <!-- 检索结果详细分析 -->
                <div class="bg-white rounded-lg shadow-sm p-6 mb-6">
                    <div class="flex justify-between items-center mb-4">
                        <h2 class="font-bold text-lg text-gray-800">检索结果分析</h2>
                        <div class="flex space-x-3">
                            <button
                                @click="exportAnalysisReport"
                                class="px-4 py-2 bg-gray-100 text-gray-700 rounded flex items-center !rounded-button whitespace-nowrap cursor-pointer">
                                <i class="fas fa-download mr-2"></i> 导出分析报告
                            </button>
                            <button
                                @click="generateTopicAnalysis"
                                class="px-4 py-2 bg-blue-600 text-white rounded flex items-center !rounded-button whitespace-nowrap cursor-pointer">
                                <i class="fas fa-chart-line mr-2"></i> 生成专题分析
                            </button>
                        </div>
                    </div>
                    <div class="grid grid-cols-2 gap-6">
                        <!-- 企业巡查覆盖率 -->
                        <div class="bg-gray-50 rounded-lg p-4">
                            <h3 class="font-bold text-base text-gray-800 mb-3">企业巡查覆盖率</h3>
                            <div id="companyCoverageChart" class="h-64" ref="companyCoverageChart"></div>
                        </div>
                        <!-- 问题类型分布 -->
                        <div class="bg-gray-50 rounded-lg p-4">
                            <h3 class="font-bold text-base text-gray-800 mb-3">问题类型分布</h3>
                            <div id="issueTypeDistributionChart" class="h-64" ref="issueTypeDistributionChart"></div>
                        </div>
                        <!-- 区域巡查对比 -->
                        <div class="bg-gray-50 rounded-lg p-4">
                            <h3 class="font-bold text-base text-gray-800 mb-3">区域巡查对比</h3>
                            <div id="regionComparisonChart" class="h-64" ref="regionComparisonChart"></div>
                        </div>
                        <!-- 整改完成率 -->
                        <div class="bg-gray-50 rounded-lg p-4">
                            <h3 class="font-bold text-base text-gray-800 mb-3">整改完成率</h3>
                            <div id="fixCompletionRateChart" class="h-64" ref="fixCompletionRateChart"></div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!-- 记录详情弹窗 -->
        <div v-if="showDetailModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
            <div class="bg-white rounded-lg shadow-xl w-3/4 max-w-5xl max-h-[80vh] overflow-y-auto">
                <div class="p-6">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="font-bold text-lg text-gray-800">巡查记录详情</h3>
                        <button
                            class="text-gray-500 hover:text-gray-700 !rounded-button whitespace-nowrap cursor-pointer"
                            @click="showDetailModal = false">
                            <i class="fas fa-times"></i>
                        </button>
                    </div>
                    <div class="grid grid-cols-3 gap-6">
                        <!-- 基本信息 -->
                        <div class="col-span-2">
                            <div class="bg-gray-50 p-4 rounded-lg mb-4">
                                <h4 class="font-semibold text-gray-800 mb-3">基本信息</h4>
                                <div class="grid grid-cols-3 gap-4">
                                    <div>
                                        <div class="text-sm text-gray-500">记录编号</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.id }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">企业名称</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.company }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">巡查类型</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.type }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">巡查人员</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.inspector }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">巡查时间</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.date }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">巡查结果</div>
                                        <div class="text-sm font-medium">
                                            <span
                                                class="px-2 py-0.5 inline-flex text-xs leading-5 font-semibold rounded-full"
                                                :class="selectedRecord.resultClass">
                                                {{ selectedRecord.result }}
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">问题数量</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.issueCount }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">报告状态</div>
                                        <div class="text-sm font-medium">
                                            <span
                                                class="px-2 py-0.5 inline-flex text-xs leading-5 font-semibold rounded-full"
                                                :class="selectedRecord.reportStatusClass">
                                                {{ selectedRecord.reportStatus }}
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">所属区域</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.region }}</div>
                                    </div>
                                </div>
                            </div>
                            <!-- 问题列表 -->
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-semibold text-gray-800 mb-3">发现问题 ({{ selectedRecord.issueCount }})</h4>
                                <div class="space-y-3">
                                    <div v-for="(issue, index) in selectedRecord.issues" :key="index"
                                        class="bg-white p-3 rounded-md shadow-sm">
                                        <div class="flex justify-between items-start">
                                            <div>
                                                <div class="text-sm font-medium text-gray-900">{{ issue.title }}</div>
                                                <div class="text-xs text-gray-500 mt-1">{{ issue.description }}</div>
                                            </div>
                                            <span
                                                class="px-2 py-0.5 inline-flex text-xs leading-5 font-semibold rounded-full"
                                                :class="issue.levelClass">
                                                {{ issue.level }}
                                            </span>
                                        </div>
                                        <div
                                            class="flex justify-between items-center mt-2 pt-2 border-t border-gray-100">
                                            <div class="text-xs text-gray-500">
                                                <span>类型: {{ issue.type }}</span>
                                                <span class="mx-2">|</span>
                                                <span>发现时间: {{ issue.foundDate }}</span>
                                            </div>
                                            <div>
                                                <span
                                                    class="px-2 py-0.5 inline-flex text-xs leading-5 font-semibold rounded-full"
                                                    :class="issue.statusClass">
                                                    {{ issue.status }}
                                                </span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- 右侧信息 -->
                        <div>
                            <!-- 巡查报告 -->
                            <div class="bg-gray-50 p-4 rounded-lg mb-4">
                                <h4 class="font-semibold text-gray-800 mb-3">巡查报告</h4>
                                <div class="bg-white p-3 rounded-md shadow-sm">
                                    <div class="flex items-center justify-between">
                                        <div class="text-sm font-medium text-gray-900">{{ selectedRecord.reportName }}
                                        </div>
                                        <span
                                            class="px-2 py-0.5 inline-flex text-xs leading-5 font-semibold rounded-full"
                                            :class="selectedRecord.reportStatusClass">
                                            {{ selectedRecord.reportStatus }}
                                        </span>
                                    </div>
                                    <div class="text-xs text-gray-500 mt-1">生成时间: {{ selectedRecord.reportDate }}</div>
                                    <div class="text-xs text-gray-500">生成人员: {{ selectedRecord.reportCreator }}</div>

                                </div>
                            </div>
                            <!-- 企业信息 -->
                            <div class="bg-gray-50 p-4 rounded-lg mb-4">
                                <h4 class="font-semibold text-gray-800 mb-3">企业信息</h4>
                                <div class="space-y-2">
                                    <div>
                                        <div class="text-sm text-gray-500">企业名称</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.company }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">企业类型</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.companyType }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">企业规模</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.companySize }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">所属区域</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.region }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">联系人</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.contact }}</div>
                                    </div>
                                    <div>
                                        <div class="text-sm text-gray-500">联系电话</div>
                                        <div class="text-sm font-medium">{{ selectedRecord.phone }}</div>
                                    </div>
                                </div>
                            </div>
                            <!-- 巡查照片 -->
                            <div class="bg-gray-50 p-4 rounded-lg">
                                <h4 class="font-semibold text-gray-800 mb-3">巡查照片</h4>
                                <div class="grid grid-cols-2 gap-2">
                                    <div v-for="(photo, index) in selectedRecord.photos" :key="index"
                                        class="relative rounded-md overflow-hidden shadow-sm">
                                        <img :src="photo.url" :alt="photo.description"
                                            class="w-full h-24 object-cover object-top">
                                        <div class="absolute bottom-0 left-0 right-0 bg-black bg-opacity-50 p-1">
                                            <div class="text-white text-xs truncate">{{ photo.description }}</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="flex justify-end space-x-3 mt-6">
                        <button
                            class="px-4 py-2 bg-gray-100 text-gray-700 rounded flex items-center !rounded-button whitespace-nowrap cursor-pointer"
                            @click="showDetailModal = false">
                            关闭
                        </button>
                        
                    </div>
                </div>
            </div>
        </div>

        <!-- 筛选弹窗 -->
        <div v-if="showFilterModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
            <div class="bg-white rounded-lg p-6 w-[500px] max-w-[90vw] max-h-[85vh] overflow-y-auto">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-lg font-semibold">筛选条件</h3>
                    <button @click="showFilterModal = false" class="text-gray-400 hover:text-gray-600">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
                
                <div class="space-y-4">
                    <!-- 巡查结果筛选 -->
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-2">巡查结果</label>
                        <div class="space-y-2">
                            <label class="flex items-center">
                                <input type="checkbox" v-model="filterOptions.status" value="合格" class="mr-2">
                                合格
                            </label>
                            <label class="flex items-center">
                                <input type="checkbox" v-model="filterOptions.status" value="不合格" class="mr-2">
                                不合格
                            </label>
                            <label class="flex items-center">
                                <input type="checkbox" v-model="filterOptions.status" value="整改中" class="mr-2">
                                整改中
                            </label>
                        </div>
                    </div>

                    <!-- 风险等级筛选 -->
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-2">风险等级</label>
                        <div class="space-y-2">
                            <label class="flex items-center">
                                <input type="checkbox" v-model="filterOptions.riskLevel" value="高风险" class="mr-2">
                                高风险
                            </label>
                            <label class="flex items-center">
                                <input type="checkbox" v-model="filterOptions.riskLevel" value="中风险" class="mr-2">
                                中风险
                            </label>
                            <label class="flex items-center">
                                <input type="checkbox" v-model="filterOptions.riskLevel" value="低风险" class="mr-2">
                                低风险
                            </label>
                        </div>
                    </div>

                    <!-- 问题数量筛选 -->
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-2">问题数量</label>
                        <div class="flex space-x-2">
                            <input type="number" v-model="filterOptions.issueCountMin" placeholder="最小值" 
                                class="flex-1 px-3 py-2 border border-gray-300 rounded-md">
                            <span class="self-center">-</span>
                            <input type="number" v-model="filterOptions.issueCountMax" placeholder="最大值" 
                                class="flex-1 px-3 py-2 border border-gray-300 rounded-md">
                        </div>
                    </div>

                    <!-- 日期范围筛选 -->
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-2">巡查日期</label>
                        <div class="flex space-x-2">
                            <input type="date" v-model="filterOptions.dateStart" 
                                class="flex-1 px-3 py-2 border border-gray-300 rounded-md">
                            <span class="self-center">-</span>
                            <input type="date" v-model="filterOptions.dateEnd" 
                                class="flex-1 px-3 py-2 border border-gray-300 rounded-md">
                        </div>
                    </div>
                </div>

                <div class="flex justify-end space-x-3 mt-6">
                    <button @click="resetFilters" 
                        class="px-4 py-2 bg-gray-100 text-gray-700 rounded hover:bg-gray-200">
                        重置
                    </button>
                    <button @click="applyFilters" 
                        class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">
                        应用筛选
                    </button>
                </div>
            </div>
        </div>

        <!-- 排序弹窗 -->
        <div v-if="showSortModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
            <div class="bg-white rounded-lg p-6 w-[400px] max-w-[90vw]">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-lg font-semibold">排序方式</h3>
                    <button @click="showSortModal = false" class="text-gray-400 hover:text-gray-600">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
                
                <div class="space-y-3">
                    <label class="flex items-center">
                        <input type="radio" v-model="sortOption" value="date-desc" class="mr-2">
                        按日期降序（最新优先）
                    </label>
                    <label class="flex items-center">
                        <input type="radio" v-model="sortOption" value="date-asc" class="mr-2">
                        按日期升序（最早优先）
                    </label>
                    <label class="flex items-center">
                        <input type="radio" v-model="sortOption" value="issues-desc" class="mr-2">
                        按问题数量降序
                    </label>
                    <label class="flex items-center">
                        <input type="radio" v-model="sortOption" value="issues-asc" class="mr-2">
                        按问题数量升序
                    </label>
                    <label class="flex items-center">
                        <input type="radio" v-model="sortOption" value="risk-desc" class="mr-2">
                        按风险等级降序
                    </label>
                    <label class="flex items-center">
                        <input type="radio" v-model="sortOption" value="company-asc" class="mr-2">
                        按企业名称升序
                    </label>
                </div>

                <div class="flex justify-end space-x-3 mt-6">
                    <button @click="showSortModal = false" 
                        class="px-4 py-2 bg-gray-100 text-gray-700 rounded hover:bg-gray-200">
                        取消
                    </button>
                    <button @click="applySorting" 
                        class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">
                        应用排序
                    </button>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import * as echarts from 'echarts';
import Header from '../components/Header.vue';
export default {
    components: {
    Header,
  },
    data() {
        return {
            mainMenus: [
                {
                    name: '监测报警',
                    icon: 'fas fa-bell',
                    expanded: false,
                    active: false,
                    subMenus: [
                        { name: '数据汇聚功能', active: false, link: '/data-aggregation' },
                        { name: '监测指标统计', active: false, link: '/monitoring-indicators' },
                        { name: '区域化展示', active: false, link: '/regional-display' }
                    ]
                },
                {
                    name: '风险研判',
                    icon: 'fas fa-exclamation-triangle',
                    expanded: false,
                    active: false,
                    subMenus: [
                        { name: '智能风险评估', active: false, link: '/intelligent-risk-assessment' },
                        { name: '预警信息推送', active: false, link: '/risk-warning-push' },
                        { name: '风险管理与分析', active: false, link: '/risk-analysis' },
                        { name: '重点风险提示', active: false, link: '/focus' },
                    ]
                },
                {
                    name: '在线巡查',
                    icon: 'fas fa-search',
                    expanded: true,
                    active: true,
                    subMenus: [
                        { name: '企业信息汇总', active: false, link: '/summary-information' },
                        { name: '巡查功能', active: false, link: '/patrol' },
                        { name: '检索功能', active: true, link: 'search' },
                        { name: '一屏汇聚展示', active: false, link: '/screen-display' }
                    ]
                },
                {
                    name: '综合分析',
                    icon: 'fas fa-chart-line',
                    expanded: false,
                    active: false,
                    subMenus: [
                        { name: '联网与设备分析', active: false, link: '/equipment' },
                        { name: '应用情况分析', active: false, link: '/application' },
                        { name: '数据质量分析', active: false, link: '/data-quality' },
                        { name: '定期专题报告', active: false, link: 'report' }
                    ]
                },
                {
                    name: '系统管理',
                    icon: 'fas fa-cog',
                    expanded: false,
                    active: false,
                    subMenus: [
                        { name: '用户权限管理', active: false, link: 'user-permission' },
                        { name: '系统配置管理', active: false, link: 'system-manage' },
                        { name: '数据管理', active: false, link: 'data-manage' },
                        { name: '系统监控与维护', active: false, link: 'monitoring' }
                    ]
                }
            ],
            showAdvancedSearch: false,
            activeDropdown: null,
            searchLoading: false,
            searchParams: {
                companyName: '',
                inspectionType: '',
                inspectionResult: '',
                timeRange: '',
                inspector: '',
                region: '',
                companySize: '',
                issueType: '',
                riskLevel: '',
                fixStatus: '',
                reportStatus: '',
                keywords: ''
            },
            resultTabs: [
                { name: '全部记录', count: 156, active: true },
                { name: '常规巡查', count: 82, active: false },
                { name: '专项巡查', count: 58, active: false },
                { name: '应急巡查', count: 16, active: false }
            ],
            activeResultTabIndex: 0, // 当前激活的结果标签页索引

            allSearchResults: [
                {
                    id: 'JL-2025-0705-001',
                    company: '河北钢铁集团有限公司',
                    type: '常规巡查',
                    inspector: '张工、王工',
                    date: '2025-07-05',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 2,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华北地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '李经理',
                    phone: '13800138001',
                    reportName: '河北钢铁集团常规巡查报告-20250705',
                    reportDate: '2025-07-05 18:30',
                    reportCreator: '张工',
                    issues: [
                        {
                            title: '废气排放监测设备校准',
                            description: '废气排放监测设备需要重新校准，确保数据准确性',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '设备维护',
                            foundDate: '2025-07-05 10:30',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        },
                        {
                            title: '安全标识更新',
                            description: '部分安全标识需要更新为最新标准',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '安全管理',
                            foundDate: '2025-07-05 14:15',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '废气排放监测设备'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产车间全景'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '安全标识牌'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '环保设施运行状态'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0704-002',
                    company: '宝山钢铁股份有限公司',
                    type: '专项巡查',
                    inspector: '李工、陈工',
                    date: '2025-07-04',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 1,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华东地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '王总监',
                    phone: '13900139002',
                    reportName: '宝山钢铁专项巡查报告-20250704',
                    reportDate: '2025-07-04 16:45',
                    reportCreator: '李工',
                    issues: [
                        {
                            title: '噪声控制优化',
                            description: '生产区域噪声控制设施需要进一步优化',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '环境保护',
                            foundDate: '2025-07-04 11:20',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '钢铁生产线'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '噪声监测设备'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0703-003',
                    company: '鞍钢股份有限公司',
                    type: '常规巡查',
                    inspector: '刘工、赵工',
                    date: '2025-07-03',
                    result: '不合格',
                    resultClass: 'bg-red-100 text-red-800',
                    issueCount: 8,
                    reportStatus: '待审核',
                    reportStatusClass: 'bg-yellow-100 text-yellow-800',
                    region: '东北地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '张厂长',
                    phone: '13700137003',
                    reportName: '鞍钢股份常规巡查报告-20250703',
                    reportDate: '2025-07-03 17:20',
                    reportCreator: '刘工',
                    issues: [
                        {
                            title: '废水处理设施故障',
                            description: '废水处理设施主要设备出现故障，影响处理效果',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '环境保护',
                            foundDate: '2025-07-03 09:15',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '安全防护设施缺失',
                            description: '高温作业区域缺少必要的安全防护设施',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '安全管理',
                            foundDate: '2025-07-03 10:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '粉尘控制不达标',
                            description: '生产车间粉尘浓度超过国家标准',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '环境保护',
                            foundDate: '2025-07-03 11:45',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '应急预案不完善',
                            description: '环境突发事件应急预案需要更新完善',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '应急管理',
                            foundDate: '2025-07-03 13:20',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '监测数据记录不规范',
                            description: '环境监测数据记录存在不规范现象',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '数据管理',
                            foundDate: '2025-07-03 14:10',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '设备维护记录缺失',
                            description: '部分关键设备缺少定期维护记录',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '设备管理',
                            foundDate: '2025-07-03 15:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '人员培训不足',
                            description: '新入职员工环保培训不够充分',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '人员管理',
                            foundDate: '2025-07-03 16:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '标识标牌老化',
                            description: '部分环保标识标牌出现老化现象',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '设施维护',
                            foundDate: '2025-07-03 16:45',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '废水处理设施'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '高温作业区域'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产车间粉尘情况'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '环保标识牌'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0702-004',
                    company: '武汉钢铁有限公司',
                    type: '应急巡查',
                    inspector: '孙工、周工',
                    date: '2025-07-02',
                    result: '整改中',
                    resultClass: 'bg-yellow-100 text-yellow-800',
                    issueCount: 5,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华中地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '陈总工',
                    phone: '13600136004',
                    reportName: '武汉钢铁应急巡查报告-20250702',
                    reportDate: '2025-07-02 19:30',
                    reportCreator: '孙工',
                    issues: [
                        {
                            title: '突发环境事件处置',
                            description: '生产过程中发生突发环境事件，需要紧急处置',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '应急处置',
                            foundDate: '2025-07-02 08:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '应急设备检修',
                            description: '应急处置设备需要立即检修维护',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '设备维护',
                            foundDate: '2025-07-02 10:15',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '应急预案执行',
                            description: '应急预案执行过程中发现流程需要优化',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '应急管理',
                            foundDate: '2025-07-02 12:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '人员应急培训',
                            description: '部分人员应急响应能力需要加强培训',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '人员管理',
                            foundDate: '2025-07-02 14:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '通讯设备故障',
                            description: '应急通讯设备出现故障，影响信息传递',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '设备维护',
                            foundDate: '2025-07-02 16:45',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '应急处置现场'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '应急设备检修'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产车间状况'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '应急通讯设备'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0701-005',
                    company: '首钢集团有限公司',
                    type: '常规巡查',
                    inspector: '吴工、郑工',
                    date: '2025-07-01',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 0,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华北地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '刘副总',
                    phone: '13500135005',
                    reportName: '首钢集团常规巡查报告-20250701',
                    reportDate: '2025-07-01 17:00',
                    reportCreator: '吴工',
                    issues: [],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产车间整体状况'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '环保设施运行良好'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '安全标识完善'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '监测设备正常'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0630-006',
                    company: '马鞍山钢铁股份有限公司',
                    type: '专项巡查',
                    inspector: '钱工、冯工',
                    date: '2025-06-30',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 3,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华东地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '马经理',
                    phone: '13400134006',
                    reportName: '马鞍山钢铁专项巡查报告-20250630',
                    reportDate: '2025-06-30 16:20',
                    reportCreator: '钱工',
                    issues: [
                        {
                            title: '废气处理优化',
                            description: '废气处理系统需要进一步优化提升',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '环境保护',
                            foundDate: '2025-06-30 10:30',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        },
                        {
                            title: '设备维护记录',
                            description: '部分设备维护记录需要完善',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '设备管理',
                            foundDate: '2025-06-30 13:15',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        },
                        {
                            title: '人员培训档案',
                            description: '新员工培训档案需要建立完善',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '人员管理',
                            foundDate: '2025-06-30 15:00',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '废气处理设施'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产车间'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '培训现场'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '设备维护'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0629-007',
                    company: '太原钢铁(集团)有限公司',
                    type: '常规巡查',
                    inspector: '陈工、林工',
                    date: '2025-06-29',
                    result: '不合格',
                    resultClass: 'bg-red-100 text-red-800',
                    issueCount: 15,
                    reportStatus: '已驳回',
                    reportStatusClass: 'bg-red-100 text-red-800',
                    region: '华北地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '太原负责人',
                    phone: '13300133007',
                    reportName: '太原钢铁常规巡查报告-20250629',
                    reportDate: '2025-06-29 18:45',
                    reportCreator: '陈工',
                    issues: [
                        {
                            title: '重大环境违规',
                            description: '存在重大环境违规行为，需要立即整改',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '环境保护',
                            foundDate: '2025-06-29 09:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '安全隐患多处',
                            description: '发现多处安全隐患，存在重大安全风险',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '安全管理',
                            foundDate: '2025-06-29 11:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '废水处理不达标',
                            description: '废水处理系统运行不正常，排放不达标',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '环境保护',
                            foundDate: '2025-06-29 14:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '设备老化严重',
                            description: '多台关键设备老化严重，存在安全隐患',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '设备管理',
                            foundDate: '2025-06-29 16:20',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '环境违规现场'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '安全隐患点'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '废水处理设施'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '老化设备'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0628-008',
                    company: '包头钢铁(集团)有限责任公司',
                    type: '应急巡查',
                    inspector: '黄工、何工',
                    date: '2025-06-28',
                    result: '整改中',
                    resultClass: 'bg-yellow-100 text-yellow-800',
                    issueCount: 7,
                    reportStatus: '待审核',
                    reportStatusClass: 'bg-yellow-100 text-yellow-800',
                    region: '华北地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '包钢负责人',
                    phone: '13200132008',
                    reportName: '包头钢铁应急巡查报告-20250628',
                    reportDate: '2025-06-28 20:30',
                    reportCreator: '黄工',
                    issues: [
                        {
                            title: '应急响应不及时',
                            description: '环境突发事件应急响应机制不够完善',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '应急管理',
                            foundDate: '2025-06-28 14:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '监测数据异常',
                            description: '部分环境监测数据出现异常波动',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '环境监测',
                            foundDate: '2025-06-28 16:20',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '设备维护滞后',
                            description: '关键环保设备维护计划执行滞后',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '设备管理',
                            foundDate: '2025-06-28 18:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '应急响应现场'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '监测设备'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '环保设施'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '维护现场'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0627-009',
                    company: '湖南华菱钢铁股份有限公司',
                    type: '常规巡查',
                    inspector: '许工、谢工',
                    date: '2025-06-27',
                    result: '不合格',
                    resultClass: 'bg-red-100 text-red-800',
                    issueCount: 12,
                    reportStatus: '已驳回',
                    reportStatusClass: 'bg-red-100 text-red-800',
                    region: '华中地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '华菱负责人',
                    phone: '13100131009',
                    reportName: '湖南华菱钢铁常规巡查报告-20250627',
                    reportDate: '2025-06-27 17:30',
                    reportCreator: '许工',
                    issues: [
                        {
                            title: '废气排放超标',
                            description: '部分废气排放指标超过国家标准',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '环境保护',
                            foundDate: '2025-06-27 10:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '噪音污染严重',
                            description: '生产区域噪音超过规定标准',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '环境保护',
                            foundDate: '2025-06-27 14:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '固废处理不当',
                            description: '工业固废处理流程存在问题',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '环境保护',
                            foundDate: '2025-06-27 16:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '废气排放口'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '噪音监测点'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '固废处理区'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '整改现场'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0626-010',
                    company: '福建三钢闽光股份有限公司',
                    type: '常规巡查',
                    inspector: '郑工、赵工',
                    date: '2025-06-26',
                    result: '整改中',
                    resultClass: 'bg-yellow-100 text-yellow-800',
                    issueCount: 6,
                    reportStatus: '待审核',
                    reportStatusClass: 'bg-yellow-100 text-yellow-800',
                    region: '华东地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '三钢联系人',
                    phone: '13000130010',
                    reportName: '福建三钢闽光常规巡查报告-20250626',
                    reportDate: '2025-06-26 16:45',
                    reportCreator: '郑工',
                    issues: [
                        {
                            title: '水质监测异常',
                            description: '废水处理后水质指标偶有异常',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '环境保护',
                            foundDate: '2025-06-26 11:20',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '设备保养记录',
                            description: '部分设备保养记录不够完整',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '设备管理',
                            foundDate: '2025-06-26 14:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '人员培训不足',
                            description: '新员工环保培训需要加强',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '人员管理',
                            foundDate: '2025-06-26 15:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '水质监测设备'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '废水处理池'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '设备保养现场'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '培训现场'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0625-011',
                    company: '江苏沙钢集团有限公司',
                    type: '常规巡查',
                    inspector: '田工、白工',
                    date: '2025-06-25',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 1,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华东地区',
                    companyType: '民营企业',
                    companySize: '大型企业',
                    contact: '沙钢负责人',
                    phone: '12900129011',
                    reportName: '江苏沙钢集团常规巡查报告-20250625',
                    reportDate: '2025-06-25 17:00',
                    reportCreator: '田工',
                    issues: [
                        {
                            title: '档案管理优化',
                            description: '环保档案管理需要进一步规范',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '档案管理',
                            foundDate: '2025-06-25 15:00',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产车间整体状况'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '环保设施运行良好'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '档案管理区域'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0624-012',
                    company: '山东钢铁集团有限公司',
                    type: '专项巡查',
                    inspector: '石工、龙工',
                    date: '2025-06-24',
                    result: '整改中',
                    resultClass: 'bg-yellow-100 text-yellow-800',
                    issueCount: 4,
                    reportStatus: '待审核',
                    reportStatusClass: 'bg-yellow-100 text-yellow-800',
                    region: '华东地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '山钢负责人',
                    phone: '12800128012',
                    reportName: '山东钢铁集团专项巡查报告-20250624',
                    reportDate: '2025-06-24 18:20',
                    reportCreator: '石工',
                    issues: [
                        {
                            title: '能耗监控异常',
                            description: '能耗监控系统数据异常，需要校准',
                            level: '一般',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '能源管理',
                            foundDate: '2025-06-24 10:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '废料回收不及时',
                            description: '生产废料回收处理不够及时',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '废料管理',
                            foundDate: '2025-06-24 14:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '能耗监控设备'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '废料回收区'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产现场'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '整改进度'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0623-013',
                    company: '新疆八一钢铁股份有限公司',
                    type: '常规巡查',
                    inspector: '马工、牛工',
                    date: '2025-06-23',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 2,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '西北地区',
                    companyType: '国有企业',
                    companySize: '中型企业',
                    contact: '八钢负责人',
                    phone: '12700127013',
                    reportName: '新疆八一钢铁常规巡查报告-20250623',
                    reportDate: '2025-06-23 16:30',
                    reportCreator: '马工',
                    issues: [
                        {
                            title: '防风抑尘网维护',
                            description: '部分防风抑尘网需要维护更新',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '环境保护',
                            foundDate: '2025-06-23 11:00',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        },
                        {
                            title: '监测设备校准',
                            description: '环境监测设备需要定期校准',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '设备管理',
                            foundDate: '2025-06-23 14:20',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '防风抑尘网'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '监测设备'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产现场'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0622-014',
                    company: '攀钢集团有限公司',
                    type: '应急巡查',
                    inspector: '羊工、猴工',
                    date: '2025-06-22',
                    result: '不合格',
                    resultClass: 'bg-red-100 text-red-800',
                    issueCount: 9,
                    reportStatus: '已驳回',
                    reportStatusClass: 'bg-red-100 text-red-800',
                    region: '西南地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '攀钢负责人',
                    phone: '12700127014',
                    reportName: '攀钢集团应急巡查报告-20250622',
                    reportDate: '2025-06-22 18:00',
                    reportCreator: '羊工',
                    issues: [
                        {
                            title: '重大安全隐患',
                            description: '发现多处重大安全隐患需要立即整改',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '安全生产',
                            foundDate: '2025-06-22 10:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '环保设施故障',
                            description: '环保设施存在故障，需要紧急维修',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '环境保护',
                            foundDate: '2025-06-22 11:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产现场'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '安全隐患点'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '环保设施'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0621-015',
                    company: '酒泉钢铁(集团)有限责任公司',
                    type: '常规巡查',
                    inspector: '鸡工、狗工',
                    date: '2025-06-21',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 0,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '西北地区',
                    companyType: '国有企业',
                    companySize: '中型企业',
                    contact: '酒钢负责人',
                    phone: '12700127015',
                    reportName: '酒泉钢铁常规巡查报告-20250621',
                    reportDate: '2025-06-21 16:30',
                    reportCreator: '鸡工',
                    issues: [],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产现场'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '环保设施'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0620-016',
                    company: '天津钢管集团股份有限公司',
                    type: '专项巡查',
                    inspector: '猪工、鼠工',
                    date: '2025-06-20',
                    result: '整改中',
                    resultClass: 'bg-yellow-100 text-yellow-800',
                    issueCount: 3,
                    reportStatus: '待审核',
                    reportStatusClass: 'bg-yellow-100 text-yellow-800',
                    region: '华北地区',
                    companyType: '国有企业',
                    companySize: '中型企业',
                    contact: '天钢负责人',
                    phone: '12700127016',
                    reportName: '天津钢管专项巡查报告-20250620',
                    reportDate: '2025-06-20 17:00',
                    reportCreator: '猪工',
                    issues: [
                        {
                            title: '设备维护问题',
                            description: '部分设备需要维护',
                            level: '一般',
                            levelClass: 'bg-orange-100 text-orange-800',
                            type: '设备管理',
                            foundDate: '2025-06-20 14:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '管道检查',
                            description: '钢管生产线需要检查',
                            level: '一般',
                            levelClass: 'bg-orange-100 text-orange-800',
                            type: '生产管理',
                            foundDate: '2025-06-20 15:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '设备检查'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '钢管生产线'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0619-017',
                    company: '广西柳州钢铁集团有限公司',
                    type: '常规巡查',
                    inspector: '牛工、虎工',
                    date: '2025-06-19',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 1,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华南地区',
                    companyType: '国有企业',
                    companySize: '中型企业',
                    contact: '柳钢负责人',
                    phone: '12700127017',
                    reportName: '柳州钢铁常规巡查报告-20250619',
                    reportDate: '2025-06-19 16:30',
                    reportCreator: '牛工',
                    issues: [
                        {
                            title: '环保设施检查',
                            description: '环保设施运行正常，有轻微维护需求',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '环境保护',
                            foundDate: '2025-06-19 11:00',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '环保设施'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产现场'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0618-018',
                    company: '重庆钢铁股份有限公司',
                    type: '应急巡查',
                    inspector: '兔工、龙工',
                    date: '2025-06-18',
                    result: '不合格',
                    resultClass: 'bg-red-100 text-red-800',
                    issueCount: 11,
                    reportStatus: '已驳回',
                    reportStatusClass: 'bg-red-100 text-red-800',
                    region: '西南地区',
                    companyType: '国有企业',
                    companySize: '中型企业',
                    contact: '重钢负责人',
                    phone: '12700127018',
                    reportName: '重庆钢铁应急巡查报告-20250618',
                    reportDate: '2025-06-18 18:30',
                    reportCreator: '兔工',
                    issues: [
                        {
                            title: '严重安全隐患',
                            description: '发现多处严重安全隐患',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '安全生产',
                            foundDate: '2025-06-18 09:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '环保违规',
                            description: '环保设施运行不正常',
                            level: '严重',
                            levelClass: 'bg-red-100 text-red-800',
                            type: '环境保护',
                            foundDate: '2025-06-18 10:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '安全隐患现场'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '环保设施'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0617-019',
                    company: '本溪钢铁(集团)有限责任公司',
                    type: '常规巡查',
                    inspector: '蛇工、马工',
                    date: '2025-06-17',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 2,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '东北地区',
                    companyType: '国有企业',
                    companySize: '中型企业',
                    contact: '本钢负责人',
                    phone: '12700127019',
                    reportName: '本溪钢铁常规巡查报告-20250617',
                    reportDate: '2025-06-17 16:00',
                    reportCreator: '蛇工',
                    issues: [
                        {
                            title: '设备保养',
                            description: '部分设备需要定期保养',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '设备管理',
                            foundDate: '2025-06-17 13:00',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        },
                        {
                            title: '安全标识更新',
                            description: '部分安全标识需要更新',
                            level: '轻微',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '安全生产',
                            foundDate: '2025-06-17 14:30',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '设备检查'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产现场'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0616-020',
                    company: '河南安阳钢铁集团有限责任公司',
                    type: '专项巡查',
                    inspector: '羊工、猴工',
                    date: '2025-06-16',
                    result: '整改中',
                    resultClass: 'bg-yellow-100 text-yellow-800',
                    issueCount: 5,
                    reportStatus: '待审核',
                    reportStatusClass: 'bg-yellow-100 text-yellow-800',
                    region: '华中地区',
                    companyType: '国有企业',
                    companySize: '中型企业',
                    contact: '安钢负责人',
                    phone: '12700127020',
                    reportName: '安阳钢铁专项巡查报告-20250616',
                    reportDate: '2025-06-16 17:30',
                    reportCreator: '羊工',
                    issues: [
                        {
                            title: '环保整改',
                            description: '环保设施需要进一步整改',
                            level: '一般',
                            levelClass: 'bg-orange-100 text-orange-800',
                            type: '环境保护',
                            foundDate: '2025-06-16 10:00',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '生产工艺优化',
                            description: '生产工艺需要优化改进',
                            level: '一般',
                            levelClass: 'bg-orange-100 text-orange-800',
                            type: '生产管理',
                            foundDate: '2025-06-16 11:30',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://images.unsplash.com/photo-1565793298595-6a879b1d9492?w=400',
                            description: '环保设施'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1504328345606-18bbc8c9d7d1?w=400',
                            description: '生产现场'
                        },
                        {
                            url: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=400',
                            description: '工艺设备'
                        }
                    ]
                }
            ],
            searchResults: [
                {
                    id: 'JL-2025-0705-001',
                    company: '河北钢铁集团有限公司',
                    type: '常规巡查',
                    inspector: '张工、王工',
                    date: '2025-07-05',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 2,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华北地区',
                    companyType: '国有企业',
                    companySize: '大型企业',
                    contact: '李经理',
                    phone: '13812345678',
                    reportName: '河北钢铁集团安全生产巡查报告',
                    reportDate: '2025-07-05',
                    reportCreator: '张工',
                    issues: [
                        {
                            title: '高炉煤气管道法兰密封不严',
                            description: '3号高炉煤气管道法兰处存在轻微泄漏，需要更换密封垫片',
                            level: '中风险',
                            levelClass: 'bg-yellow-100 text-yellow-800',
                            type: '设备隐患',
                            foundDate: '2025-07-05',
                            status: '整改中',
                            statusClass: 'bg-yellow-100 text-yellow-800'
                        },
                        {
                            title: '消防通道堆放杂物',
                            description: '2号车间消防通道堆放有生产物料，影响紧急疏散',
                            level: '低风险',
                            levelClass: 'bg-blue-100 text-blue-800',
                            type: '消防隐患',
                            foundDate: '2025-07-05',
                            status: '已整改',
                            statusClass: 'bg-green-100 text-green-800'
                        }
                    ],
                    photos: [
                        {
                            url: 'https://readdy.ai/api/search-image?query=Close-up%20industrial%20photograph%20of%20a%20steel%20factory%20high-pressure%20gas%20pipeline%20with%20visible%20flange%20connection%20showing%20minor%20gas%20leakage.%20The%20image%20captures%20the%20technical%20details%20of%20the%20pipeline%20joint%20with%20clear%20industrial%20background%20and%20professional%20lighting%20to%20highlight%20the%20safety%20issue&width=300&height=200&seq=1&orientation=landscape',
                            description: '高炉煤气管道法兰泄漏点'
                        },
                        {
                            url: 'https://readdy.ai/api/search-image?query=Industrial%20safety%20inspection%20photograph%20showing%20a%20fire%20evacuation%20route%20in%20a%20steel%20factory%20that%20is%20partially%20blocked%20by%20production%20materials%20and%20equipment.%20The%20image%20clearly%20shows%20the%20obstruction%20in%20a%20well-lit%20factory%20environment%20with%20safety%20markings%20visible%20on%20the%20floor&width=300&height=200&seq=2&orientation=landscape',
                            description: '消防通道堆放物料'
                        },
                        {
                            url: 'https://readdy.ai/api/search-image?query=Professional%20inspection%20photograph%20of%20a%20steel%20factory%20blast%20furnace%20area%20showing%20the%20main%20production%20equipment%20with%20safety%20inspectors%20in%20high-visibility%20clothing%20conducting%20checks.%20The%20image%20shows%20a%20well-maintained%20industrial%20environment%20with%20proper%20lighting%20and%20clear%20visibility%20of%20safety%20features&width=300&height=200&seq=3&orientation=landscape',
                            description: '高炉区域巡查'
                        },
                        {
                            url: 'https://readdy.ai/api/search-image?query=Close-up%20photograph%20of%20an%20industrial%20control%20panel%20in%20a%20steel%20factory%20showing%20gauges%2C%20meters%20and%20control%20systems%20being%20inspected.%20The%20image%20shows%20a%20professional%20taking%20readings%20or%20checking%20the%20equipment%20with%20proper%20lighting%20to%20highlight%20the%20technical%20details&width=300&height=200&seq=4&orientation=landscape',
                            description: '控制系统检查'
                        }
                    ]
                },
                {
                    id: 'JL-2025-0704-002',
                    company: '山东泰山钢铁有限公司',
                    type: '专项巡查',
                    inspector: '李工、赵工',
                    date: '2025-07-04',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 3,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华东地区'
                },
                {
                    id: 'JL-2025-0703-003',
                    company: '江苏沿海钢铁集团',
                    type: '常规巡查',
                    inspector: '王工、钱工',
                    date: '2025-07-03',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 1,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华东地区'
                },
                {
                    id: 'JL-2025-0702-004',
                    company: '辽宁鞍钢集团有限公司',
                    type: '常规巡查',
                    inspector: '赵工、孙工',
                    date: '2025-07-02',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 0,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '东北地区'
                },
                {
                    id: 'JL-2025-0701-005',
                    company: '云南昆钢钢铁集团',
                    type: '专项巡查',
                    inspector: '周工、吴工',
                    date: '2025-07-01',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 2,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '西南地区'
                },
                {
                    id: 'JL-2025-0630-006',
                    company: '广东韶钢松山股份有限公司',
                    type: '常规巡查',
                    inspector: '吴工、郑工',
                    date: '2025-06-30',
                    result: '合格',
                    resultClass: 'bg-green-100 text-green-800',
                    issueCount: 1,
                    reportStatus: '已生成',
                    reportStatusClass: 'bg-green-100 text-green-800',
                    region: '华南地区'
                },
                {
                    id: 'JL-2025-0629-007',
                    company: '湖北武钢有限责任公司',
                    type: '专项巡查',
                    inspector: '刘工、张工',
                    date: '2025-06-29',
                    result: '不合格',
                    resultClass: 'bg-red-100 text-red-800',
                    issueCount: 8,
                    reportStatus: '待审核',
                    reportStatusClass: 'bg-yellow-100 text-yellow-800',
                    region: '华中地区'
                },
                {
                    id: 'JL-2025-0628-008',
                    company: '重庆钢铁股份有限公司',
                    type: '专项巡查',
                    inspector: '孙工、李工',
                    date: '2025-06-28',
                    result: '整改中',
                    resultClass: 'bg-yellow-100 text-yellow-800',
                    issueCount: 5,
                    reportStatus: '待审核',
                    reportStatusClass: 'bg-yellow-100 text-yellow-800',
                    region: '西南地区'
                },
                {
                    id: 'JL-2025-0627-009',
                    company: '河南安阳钢铁厂',
                    type: '专项巡查',
                    inspector: '钱工、王工',
                    date: '2025-06-27',
                    result: '不合格',
                    resultClass: 'bg-red-100 text-red-800',
                    issueCount: 12,
                    reportStatus: '已驳回',
                    reportStatusClass: 'bg-red-100 text-red-800',
                    region: '华中地区'
                },
                {
                    id: 'JL-2025-0626-010',
                    company: '福建三钢闽光股份有限公司',
                    type: '常规巡查',
                    inspector: '郑工、赵工',
                    date: '2025-06-26',
                    result: '整改中',
                    resultClass: 'bg-yellow-100 text-yellow-800',
                    issueCount: 6,
                    reportStatus: '待审核',
                    reportStatusClass: 'bg-yellow-100 text-yellow-800',
                    region: '华东地区'
                }
            ],
            showDetailModal: false,
            selectedRecord: {},
            // 筛选和排序相关
            showFilterModal: false,
            showSortModal: false,
            filterOptions: {
                status: [],
                riskLevel: [],
                issueCountMin: null,
                issueCountMax: null,
                dateStart: '',
                dateEnd: ''
            },
            sortOption: 'date-desc',
            // 分页相关
            currentPage: 1,
            pageSize: 10,
            totalItems: 0
        };
    },
    computed: {
        hasActiveFilters() {
            return Object.keys(this.activeFilters).length > 0;
        },
        activeFilters() {
            const filters = {};
            for (const key in this.searchParams) {
                if (this.searchParams[key] && this.searchParams[key] !== '全部类型' &&
                    this.searchParams[key] !== '全部结果' && this.searchParams[key] !== '全部时间' &&
                    this.searchParams[key] !== '全部区域' && this.searchParams[key] !== '全部规模' &&
                    this.searchParams[key] !== '全部等级' && this.searchParams[key] !== '全部状态') {
                    filters[key] = this.searchParams[key];
                }
            }
            return filters;
        },
        // 分页相关计算属性
        totalPages() {
            return Math.ceil(this.totalItems / this.pageSize);
        },
        paginatedResults() {
            const start = (this.currentPage - 1) * this.pageSize;
            const end = start + this.pageSize;
            return this.searchResults.slice(start, end);
        },
        paginationInfo() {
            const start = this.totalItems === 0 ? 0 : (this.currentPage - 1) * this.pageSize + 1;
            const end = Math.min(this.currentPage * this.pageSize, this.totalItems);
            return {
                start,
                end,
                total: this.totalItems
            };
        },
        visiblePageNumbers() {
            const pages = [];
            const maxVisible = 5; // 最多显示5个页码
            
            if (this.totalPages <= maxVisible) {
                // 如果总页数小于等于最大显示数，显示所有页码
                for (let i = 1; i <= this.totalPages; i++) {
                    pages.push(i);
                }
            } else {
                // 否则显示当前页附近的页码
                let start = Math.max(1, this.currentPage - 2);
                let end = Math.min(this.totalPages, start + maxVisible - 1);
                
                // 调整起始位置，确保显示足够的页码
                if (end - start + 1 < maxVisible) {
                    start = Math.max(1, end - maxVisible + 1);
                }
                
                for (let i = start; i <= end; i++) {
                    pages.push(i);
                }
            }
            
            return pages;
        }
    },
    mounted() {
        this.initInspectionTypeChart();
        this.initInspectionResultChart();
        this.initInspectionTrendChart();
        // 初始化标签页过滤
        this.filterResultsByTab();
        this.initCompanyCoverageChart();
        this.initIssueTypeDistributionChart();
        this.initRegionComparisonChart();
        this.initFixCompletionRateChart();
        // 响应窗口大小变化
        window.addEventListener('resize', this.handleResize);
        // 点击页面其他区域关闭下拉菜单
        document.addEventListener('click', this.closeDropdowns);
    },
    beforeDestroy() {
        window.removeEventListener('resize', this.handleResize);
        document.removeEventListener('click', this.closeDropdowns);
    },
    methods: {
        toggleMenu(index) {
            this.mainMenus[index].expanded = !this.mainMenus[index].expanded;
            // 如果展开了菜单，则将其他菜单收起
            if (this.mainMenus[index].expanded) {
                this.mainMenus.forEach((menu, i) => {
                    if (i !== index) {
                        menu.expanded = false;
                    }
                });
            }
        },
        selectSubmenu(menuIndex, submenuIndex) {
            // 重置所有菜单的激活状态
            this.mainMenus.forEach(menu => {
                menu.active = false;
                menu.subMenus.forEach(submenu => {
                    submenu.active = false;
                });
            });
            // 设置当前选中的菜单和子菜单为激活状态
            this.mainMenus[menuIndex].active = true;
            this.mainMenus[menuIndex].subMenus[submenuIndex].active = true;
            const link = this.mainMenus[menuIndex].subMenus[submenuIndex].link;
            if (link) {
                const dest = link.startsWith('/') ? link : `/${link}`;
                this.$router.push(dest);
            }
        },
        toggleAdvancedSearch() {
            this.showAdvancedSearch = !this.showAdvancedSearch;
        },
        toggleDropdown(dropdownName, event) {
            if (event) {
                event.stopPropagation();
            }
            if (this.activeDropdown === dropdownName) {
                this.activeDropdown = null;
            } else {
                this.activeDropdown = dropdownName;
            }
        },
        closeDropdowns(event) {
            // 如果点击的不是下拉菜单内的元素，则关闭所有下拉菜单
            if (!event.target.closest('.relative')) {
                this.activeDropdown = null;
            }
        },
        selectDropdownItem(dropdownName, value) {
            this.searchParams[dropdownName] = value;
            this.activeDropdown = null;
        },
        setActiveResultTab(index) {
            this.resultTabs.forEach((tab, i) => {
                tab.active = i === index;
            });
            this.activeResultTabIndex = index;
            this.filterResultsByTab();
        },
        // 根据标签页过滤结果
        filterResultsByTab() {
            const activeTab = this.resultTabs[this.activeResultTabIndex];
            let filteredResults = [...this.allSearchResults];
            
            // 根据标签页名称过滤数据
            if (activeTab.name === '全部记录') {
                // 显示所有记录，不需要过滤
                filteredResults = [...this.allSearchResults];
            } else if (activeTab.name === '常规巡查') {
                filteredResults = this.allSearchResults.filter(item => item.type === '常规巡查');
            } else if (activeTab.name === '专项巡查') {
                filteredResults = this.allSearchResults.filter(item => item.type === '专项巡查');
            } else if (activeTab.name === '应急巡查') {
                filteredResults = this.allSearchResults.filter(item => item.type === '应急巡查');
            }
            
            // 应用其他已有的筛选条件（如果有的话）
            this.searchResults = filteredResults;
            this.updateTabCounts();
            this.updateCharts();
            this.updateTotalItems();
        },
        // 更新标签页计数
        updateTabCounts() {
            this.resultTabs[0].count = this.allSearchResults.length; // 全部记录
            this.resultTabs[1].count = this.allSearchResults.filter(item => item.type === '常规巡查').length;
            this.resultTabs[2].count = this.allSearchResults.filter(item => item.type === '专项巡查').length;
            this.resultTabs[3].count = this.allSearchResults.filter(item => item.type === '应急巡查').length;
        },
        performSearch() {
            // 设置加载状态
            this.searchLoading = true;
            
            // 模拟API调用延迟
            setTimeout(() => {
                // 根据搜索条件过滤数据
                let filteredResults = [...this.allSearchResults];
                
                // 企业名称过滤
                if (this.searchParams.companyName) {
                    filteredResults = filteredResults.filter(item => 
                        item.company.includes(this.searchParams.companyName)
                    );
                }
                
                // 巡查类型过滤
                if (this.searchParams.inspectionType && this.searchParams.inspectionType !== '全部类型') {
                    filteredResults = filteredResults.filter(item => 
                        item.type === this.searchParams.inspectionType
                    );
                }
                
                // 巡查结果过滤
                if (this.searchParams.inspectionResult && this.searchParams.inspectionResult !== '全部结果') {
                    filteredResults = filteredResults.filter(item => 
                        item.result === this.searchParams.inspectionResult
                    );
                }
                
                // 时间范围过滤
                if (this.searchParams.timeRange && this.searchParams.timeRange !== '全部时间') {
                    const today = new Date();
                    let startDate;
                    
                    switch (this.searchParams.timeRange) {
                        case '近一周':
                            startDate = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000);
                            break;
                        case '近一月':
                            startDate = new Date(today.getTime() - 30 * 24 * 60 * 60 * 1000);
                            break;
                        case '近三月':
                            startDate = new Date(today.getTime() - 90 * 24 * 60 * 60 * 1000);
                            break;
                        default:
                            startDate = null;
                    }
                    
                    if (startDate) {
                        filteredResults = filteredResults.filter(item => {
                            const itemDate = new Date(item.date);
                            return itemDate >= startDate;
                        });
                    }
                }
                
                // 巡查人员过滤
                if (this.searchParams.inspector) {
                    filteredResults = filteredResults.filter(item => 
                        item.inspector.includes(this.searchParams.inspector)
                    );
                }
                
                // 所属区域过滤
                if (this.searchParams.region && this.searchParams.region !== '全部区域') {
                    filteredResults = filteredResults.filter(item => 
                        item.region === this.searchParams.region
                    );
                }
                
                // 企业规模过滤
                if (this.searchParams.companySize && this.searchParams.companySize !== '全部规模') {
                    filteredResults = filteredResults.filter(item => 
                        item.companySize === this.searchParams.companySize
                    );
                }
                
                // 风险等级过滤（基于问题数量判断）
                if (this.searchParams.riskLevel && this.searchParams.riskLevel !== '全部等级') {
                    filteredResults = filteredResults.filter(item => {
                        if (this.searchParams.riskLevel === '高风险' && item.issueCount >= 8) return true;
                        if (this.searchParams.riskLevel === '中风险' && item.issueCount >= 3 && item.issueCount < 8) return true;
                        if (this.searchParams.riskLevel === '低风险' && item.issueCount < 3) return true;
                        return false;
                    });
                }
                
                // 整改状态过滤
                if (this.searchParams.fixStatus && this.searchParams.fixStatus !== '全部状态') {
                    filteredResults = filteredResults.filter(item => {
                        if (this.searchParams.fixStatus === '已整改' && item.result === '合格') return true;
                        if (this.searchParams.fixStatus === '整改中' && item.result === '整改中') return true;
                        if (this.searchParams.fixStatus === '未整改' && item.result === '不合格') return true;
                        return false;
                    });
                }
                
                // 关键词搜索
                if (this.searchParams.keywords) {
                    const keywords = this.searchParams.keywords.toLowerCase();
                    filteredResults = filteredResults.filter(item => 
                        item.company.toLowerCase().includes(keywords) ||
                        item.inspector.toLowerCase().includes(keywords) ||
                        item.type.toLowerCase().includes(keywords) ||
                        item.result.toLowerCase().includes(keywords) ||
                        item.region.toLowerCase().includes(keywords)
                    );
                }
                
                // 应用标签页过滤
                const activeTab = this.resultTabs[this.activeResultTabIndex];
                if (activeTab.name !== '全部记录') {
                    if (activeTab.name === '常规巡查') {
                        filteredResults = filteredResults.filter(item => item.type === '常规巡查');
                    } else if (activeTab.name === '专项巡查') {
                        filteredResults = filteredResults.filter(item => item.type === '专项巡查');
                    } else if (activeTab.name === '应急巡查') {
                        filteredResults = filteredResults.filter(item => item.type === '应急巡查');
                    }
                }
                
                // 更新搜索结果
                this.searchResults = filteredResults;
                
                // 更新标签页计数
                this.updateTabCounts();
                
                // 更新图表数据
                this.updateChartsWithSearchResults(filteredResults);
                
                // 关闭加载状态
                this.searchLoading = false;
                
                
            }, 800); // 模拟800ms的API调用延迟
        },
        getFilterLabel(key) {
            const labels = {
                companyName: '企业名称',
                inspectionType: '巡查类型',
                inspectionResult: '巡查结果',
                timeRange: '时间范围',
                inspector: '巡查人员',
                region: '所属区域',
                companySize: '企业规模',
                issueType: '问题类型',
                riskLevel: '风险等级',
                fixStatus: '整改状态',
                reportStatus: '报告状态',
                keywords: '关键词'
            };
            return labels[key] || key;
        },
        removeFilter(key) {
            this.searchParams[key] = '';
        },
        clearAllFilters() {
            for (const key in this.searchParams) {
                this.searchParams[key] = '';
            }
        },
        showRecordDetail(record) {
            this.selectedRecord = record;
            this.showDetailModal = true;
        },
        updateChartsWithSearchResults(results) {
            // 更新巡查类型分布图
            this.updateInspectionTypeChart(results);
            // 更新巡查结果分布图
            this.updateInspectionResultChart(results);
            // 更新巡查趋势图
            this.updateInspectionTrendChart(results);
        },
        updateInspectionTypeChart(results) {
            if (!this.$refs.inspectionTypeChart) return;
            const chart = echarts.getInstanceByDom(this.$refs.inspectionTypeChart);
            if (!chart) return;
            
            // 统计巡查类型数据
            const typeCount = {};
            results.forEach(item => {
                typeCount[item.type] = (typeCount[item.type] || 0) + 1;
            });
            
            const data = [
                { value: typeCount['常规巡查'] || 0, name: '常规巡查', itemStyle: { color: '#4299e1' } },
                { value: typeCount['专项巡查'] || 0, name: '专项巡查', itemStyle: { color: '#ecc94b' } },
                { value: typeCount['应急巡查'] || 0, name: '应急巡查', itemStyle: { color: '#f56565' } },
                { value: typeCount['复查'] || 0, name: '复查', itemStyle: { color: '#805ad5' } }
            ];
            
            chart.setOption({
                series: [{
                    data: data
                }]
            });
        },
        updateInspectionResultChart(results) {
            if (!this.$refs.inspectionResultChart) return;
            const chart = echarts.getInstanceByDom(this.$refs.inspectionResultChart);
            if (!chart) return;
            
            // 统计巡查结果数据
            const resultCount = {};
            results.forEach(item => {
                resultCount[item.result] = (resultCount[item.result] || 0) + 1;
            });
            
            const data = [
                { value: resultCount['合格'] || 0, name: '合格', itemStyle: { color: '#48bb78' } },
                { value: resultCount['不合格'] || 0, name: '不合格', itemStyle: { color: '#f56565' } },
                { value: resultCount['整改中'] || 0, name: '整改中', itemStyle: { color: '#ecc94b' } }
            ];
            
            chart.setOption({
                series: [{
                    data: data
                }]
            });
        },
        updateInspectionTrendChart(results) {
            if (!this.$refs.inspectionTrendChart) return;
            const chart = echarts.getInstanceByDom(this.$refs.inspectionTrendChart);
            if (!chart) return;
            
            // 按日期统计数据
            const dateCount = {};
            const issueCount = {};
            
            results.forEach(item => {
                const date = item.date.split(' ')[0]; // 只取日期部分
                dateCount[date] = (dateCount[date] || 0) + 1;
                issueCount[date] = (issueCount[date] || 0) + (item.issueCount || 0);
            });
            
            // 获取所有有数据的日期并排序
            const allDates = Object.keys(dateCount).sort();
            
            // 如果没有数据，显示最近7天
            let dates = [];
            let inspectionCounts = [];
            let issueCounts = [];
            
            if (allDates.length === 0) {
                // 没有数据时显示最近7天
                const today = new Date();
                for (let i = 6; i >= 0; i--) {
                    const date = new Date(today.getTime() - i * 24 * 60 * 60 * 1000);
                    const monthDay = `${date.getMonth() + 1}/${date.getDate()}`;
                    dates.push(monthDay);
                    inspectionCounts.push(0);
                    issueCounts.push(0);
                }
            } else {
                // 有数据时显示实际数据的日期分布（最多显示最近10天的数据）
                const displayDates = allDates.slice(-10);
                displayDates.forEach(dateStr => {
                    const date = new Date(dateStr);
                    const monthDay = `${date.getMonth() + 1}/${date.getDate()}`;
                    dates.push(monthDay);
                    inspectionCounts.push(dateCount[dateStr] || 0);
                    issueCounts.push(issueCount[dateStr] || 0);
                });
            }
            
            chart.setOption({
                xAxis: {
                    data: dates
                },
                series: [
                    {
                        data: inspectionCounts
                    },
                    {
                        data: issueCounts
                    }
                ]
            });
        },
        handleResize() {
            const charts = [
                this.$refs.inspectionTypeChart,
                this.$refs.inspectionResultChart,
                this.$refs.inspectionTrendChart,
                this.$refs.companyCoverageChart,
                this.$refs.issueTypeDistributionChart,
                this.$refs.regionComparisonChart,
                this.$refs.fixCompletionRateChart
            ];
            charts.forEach(ref => {
                if (ref) {
                    const chart = echarts.getInstanceByDom(ref);
                    if (chart) {
                        chart.resize();
                    }
                }
            });
        },
        initInspectionTypeChart() {
            if (!this.$refs.inspectionTypeChart) return;
            const chart = echarts.init(this.$refs.inspectionTypeChart);
            
            // 统计当前搜索结果的巡查类型数据
            const typeCount = {};
            const currentResults = this.searchResults.length > 0 ? this.searchResults : this.allSearchResults;
            currentResults.forEach(item => {
                typeCount[item.type] = (typeCount[item.type] || 0) + 1;
            });
            
            const data = [
                { value: typeCount['常规巡查'] || 0, name: '常规巡查', itemStyle: { color: '#4299e1' } },
                { value: typeCount['专项巡查'] || 0, name: '专项巡查', itemStyle: { color: '#ecc94b' } },
                { value: typeCount['应急巡查'] || 0, name: '应急巡查', itemStyle: { color: '#f56565' } },
                { value: typeCount['复查'] || 0, name: '复查', itemStyle: { color: '#805ad5' } }
            ];
            
            const option = {
                animation: false,
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b}: {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    right: 10,
                    top: 'center',
                    data: ['常规巡查', '专项巡查', '应急巡查', '复查']
                },
                series: [
                    {
                        name: '巡查类型',
                        type: 'pie',
                        radius: ['45%', '70%'],
                        avoidLabelOverlap: false,
                        itemStyle: {
                            borderRadius: 10,
                            borderColor: '#fff',
                            borderWidth: 2
                        },
                        label: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            label: {
                                show: true,
                                fontSize: '14',
                                fontWeight: 'bold'
                            }
                        },
                        labelLine: {
                            show: false
                        },
                        data: data
                    }
                ]
            };
            chart.setOption(option);
        },
        initInspectionResultChart() {
            if (!this.$refs.inspectionResultChart) return;
            const chart = echarts.init(this.$refs.inspectionResultChart);
            
            // 统计当前搜索结果的巡查结果数据
            const resultCount = {};
            const currentResults = this.searchResults.length > 0 ? this.searchResults : this.allSearchResults;
            currentResults.forEach(item => {
                resultCount[item.result] = (resultCount[item.result] || 0) + 1;
            });
            
            const data = [
                { value: resultCount['合格'] || 0, name: '合格', itemStyle: { color: '#48bb78' } },
                { value: resultCount['不合格'] || 0, name: '不合格', itemStyle: { color: '#f56565' } },
                { value: resultCount['整改中'] || 0, name: '整改中', itemStyle: { color: '#ecc94b' } }
            ];
            
            const option = {
                animation: false,
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b}: {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    right: 10,
                    top: 'center',
                    data: ['合格', '不合格', '整改中']
                },
                series: [
                    {
                        name: '巡查结果',
                        type: 'pie',
                        radius: ['45%', '70%'],
                        avoidLabelOverlap: false,
                        itemStyle: {
                            borderRadius: 10,
                            borderColor: '#fff',
                            borderWidth: 2
                        },
                        label: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            label: {
                                show: true,
                                fontSize: '14',
                                fontWeight: 'bold'
                            }
                        },
                        labelLine: {
                            show: false
                        },
                        data: data
                    }
                ]
            };
            chart.setOption(option);
        },
        initInspectionTrendChart() {
            if (!this.$refs.inspectionTrendChart) return;
            const chart = echarts.init(this.$refs.inspectionTrendChart);
            
            // 统计当前搜索结果的趋势数据
            const currentResults = this.searchResults.length > 0 ? this.searchResults : this.allSearchResults;
            const dateCount = {};
            const issueCount = {};
            
            // 按日期统计数据
            currentResults.forEach(item => {
                const date = item.date.split(' ')[0]; // 只取日期部分
                dateCount[date] = (dateCount[date] || 0) + 1;
                issueCount[date] = (issueCount[date] || 0) + (item.issueCount || 0);
            });
            
            // 获取所有有数据的日期并排序
            const allDates = Object.keys(dateCount).sort();
            
            // 如果没有数据，显示最近7天
            let dates = [];
            let inspectionCounts = [];
            let issueCounts = [];
            
            if (allDates.length === 0) {
                // 没有数据时显示最近7天
                const today = new Date();
                for (let i = 6; i >= 0; i--) {
                    const date = new Date(today.getTime() - i * 24 * 60 * 60 * 1000);
                    const monthDay = `${date.getMonth() + 1}/${date.getDate()}`;
                    dates.push(monthDay);
                    inspectionCounts.push(0);
                    issueCounts.push(0);
                }
            } else {
                // 有数据时显示实际数据的日期分布（最多显示最近10天的数据）
                const displayDates = allDates.slice(-10);
                displayDates.forEach(dateStr => {
                    const date = new Date(dateStr);
                    const monthDay = `${date.getMonth() + 1}/${date.getDate()}`;
                    dates.push(monthDay);
                    inspectionCounts.push(dateCount[dateStr] || 0);
                    issueCounts.push(issueCount[dateStr] || 0);
                });
            }
            
            const option = {
                animation: false,
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross',
                        label: {
                            backgroundColor: '#6a7985'
                        }
                    }
                },
                legend: {
                    data: ['巡查次数', '发现问题数'],
                    top: 0,
                    right: 0
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    top: '25%',
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        boundaryGap: false,
                        data: dates,
                        axisLine: {
                            lineStyle: {
                                color: '#e2e8f0'
                            }
                        },
                        axisLabel: {
                            color: '#718096'
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        axisLine: {
                            show: false
                        },
                        axisTick: {
                            show: false
                        },
                        axisLabel: {
                            color: '#718096'
                        },
                        splitLine: {
                            lineStyle: {
                                color: '#e2e8f0'
                            }
                        }
                    }
                ],
                series: [
                    {
                        name: '巡查次数',
                        type: 'line',
                        stack: 'Total',
                        areaStyle: {},
                        emphasis: {
                            focus: 'series'
                        },
                        data: inspectionCounts,
                        itemStyle: {
                            color: '#4299e1'
                        }
                    },
                    {
                        name: '发现问题数',
                        type: 'line',
                        stack: 'Total',
                        areaStyle: {},
                        emphasis: {
                            focus: 'series'
                        },
                        data: issueCounts,
                        itemStyle: {
                            color: '#f56565'
                        }
                    }
                ]
            };
            chart.setOption(option);
        },
        initCompanyCoverageChart() {
            if (!this.$refs.companyCoverageChart) return;
            const chart = echarts.init(this.$refs.companyCoverageChart);
            const option = {
                animation: false,
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b}: {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    right: 10,
                    top: 'center',
                    data: ['已巡查', '未巡查']
                },
                series: [
                    {
                        name: '企业巡查覆盖',
                        type: 'pie',
                        radius: ['45%', '70%'],
                        avoidLabelOverlap: false,
                        itemStyle: {
                            borderRadius: 10,
                            borderColor: '#fff',
                            borderWidth: 2
                        },
                        label: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            label: {
                                show: true,
                                fontSize: '14',
                                fontWeight: 'bold'
                            }
                        },
                        labelLine: {
                            show: false
                        },
                        data: [
                            { value: 156, name: '已巡查', itemStyle: { color: '#4299e1' } },
                            { value: 30, name: '未巡查', itemStyle: { color: '#a0aec0' } }
                        ]
                    }
                ]
            };
            chart.setOption(option);
        },
        initIssueTypeDistributionChart() {
            if (!this.$refs.issueTypeDistributionChart) return;
            const chart = echarts.init(this.$refs.issueTypeDistributionChart);
            const option = {
                animation: false,
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    }
                },
                legend: {
                    data: ['高风险', '中风险', '低风险'],
                    top: 0,
                    right: 0
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    top: '25%',
                    containLabel: true
                },
                xAxis: {
                    type: 'value',
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    axisLabel: {
                        color: '#718096'
                    },
                    splitLine: {
                        lineStyle: {
                            color: '#e2e8f0'
                        }
                    }
                },
                yAxis: {
                    type: 'category',
                    data: ['设备隐患', '工艺隐患', '消防隐患', '电气隐患', '特种设备', '其他隐患'],
                    axisLine: {
                        lineStyle: {
                            color: '#e2e8f0'
                        }
                    },
                    axisLabel: {
                        color: '#718096'
                    }
                },
                series: [
                    {
                        name: '高风险',
                        type: 'bar',
                        stack: 'total',
                        emphasis: {
                            focus: 'series'
                        },
                        itemStyle: {
                            color: '#f56565'
                        },
                        data: [18, 12, 8, 10, 15, 5]
                    },
                    {
                        name: '中风险',
                        type: 'bar',
                        stack: 'total',
                        emphasis: {
                            focus: 'series'
                        },
                        itemStyle: {
                            color: '#ecc94b'
                        },
                        data: [35, 20, 15, 12, 10, 8]
                    },
                    {
                        name: '低风险',
                        type: 'bar',
                        stack: 'total',
                        emphasis: {
                            focus: 'series'
                        },
                        itemStyle: {
                            color: '#48bb78'
                        },
                        data: [25, 18, 12, 8, 5, 7]
                    }
                ]
            };
            chart.setOption(option);
        },
        initRegionComparisonChart() {
            if (!this.$refs.regionComparisonChart) return;
            const chart = echarts.init(this.$refs.regionComparisonChart);
            const option = {
                animation: false,
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    }
                },
                legend: {
                    data: ['巡查次数', '发现问题数'],
                    top: 0,
                    right: 0
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    top: '25%',
                    containLabel: true
                },
                xAxis: {
                    type: 'category',
                    data: ['华北', '华东', '华南', '华中', '西北', '西南', '东北'],
                    axisLine: {
                        lineStyle: {
                            color: '#e2e8f0'
                        }
                    },
                    axisLabel: {
                        color: '#718096'
                    }
                },
                yAxis: {
                    type: 'value',
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    axisLabel: {
                        color: '#718096'
                    },
                    splitLine: {
                        lineStyle: {
                            color: '#e2e8f0'
                        }
                    }
                },
                series: [
                    {
                        name: '巡查次数',
                        type: 'bar',
                        emphasis: {
                            focus: 'series'
                        },
                        itemStyle: {
                            color: '#4299e1'
                        },
                        data: [32, 28, 24, 22, 18, 16, 16]
                    },
                    {
                        name: '发现问题数',
                        type: 'bar',
                        emphasis: {
                            focus: 'series'
                        },
                        itemStyle: {
                            color: '#f56565'
                        },
                        data: [85, 72, 58, 45, 38, 28, 16]
                    }
                ]
            };
            chart.setOption(option);
        },
        initFixCompletionRateChart() {
            if (!this.$refs.fixCompletionRateChart) return;
            const chart = echarts.init(this.$refs.fixCompletionRateChart);
            const option = {
                animation: false,
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross',
                        label: {
                            backgroundColor: '#6a7985'
                        }
                    }
                },
                legend: {
                    data: ['发现问题数', '已整改数', '整改率'],
                    top: 0,
                    right: 0
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    top: '25%',
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        boundaryGap: false,
                        data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月'],
                        axisLine: {
                            lineStyle: {
                                color: '#e2e8f0'
                            }
                        },
                        axisLabel: {
                            color: '#718096'
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        name: '问题数',
                        position: 'left',
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: '#f56565'
                            }
                        },
                        axisLabel: {
                            formatter: '{value}',
                            color: '#f56565'
                        },
                        splitLine: {
                            lineStyle: {
                                color: '#e2e8f0'
                            }
                        }
                    },
                    {
                        type: 'value',
                        name: '整改率',
                        min: 0,
                        max: 100,
                        position: 'right',
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: '#48bb78'
                            }
                        },
                        axisLabel: {
                            formatter: '{value}%',
                            color: '#48bb78'
                        },
                        splitLine: {
                            show: false
                        }
                    }
                ],
                series: [
                    {
                        name: '发现问题数',
                        type: 'bar',
                        yAxisIndex: 0,
                        data: [45, 52, 48, 60, 55, 65, 70],
                        itemStyle: {
                            color: '#f56565'
                        }
                    },
                    {
                        name: '已整改数',
                        type: 'bar',
                        yAxisIndex: 0,
                        data: [30, 40, 38, 48, 45, 55, 55],
                        itemStyle: {
                            color: '#4299e1'
                        }
                    },
                    {
                        name: '整改率',
                        type: 'line',
                        yAxisIndex: 1,
                        data: [67, 77, 79, 80, 82, 85, 78],
                        itemStyle: {
                            color: '#48bb78'
                        }
                    }
                ]
            };
            chart.setOption(option);
        },
        // 筛选相关方法
        resetFilters() {
            this.filterOptions = {
                status: [],
                riskLevel: [],
                issueCountMin: null,
                issueCountMax: null,
                dateStart: '',
                dateEnd: ''
            };
        },
        applyFilters() {
            this.showFilterModal = false;
            this.filterSearchResults();
        },
        filterSearchResults() {
            let filtered = [...this.allSearchResults];
            
            // 按巡查结果筛选
            if (this.filterOptions.status.length > 0) {
                filtered = filtered.filter(item => 
                    this.filterOptions.status.includes(item.result)
                );
            }
            
            // 按风险等级筛选（基于问题数量判断风险等级）
            if (this.filterOptions.riskLevel.length > 0) {
                filtered = filtered.filter(item => {
                    let riskLevel = '低风险';
                    if (item.issueCount >= 8) riskLevel = '高风险';
                    else if (item.issueCount >= 4) riskLevel = '中风险';
                    return this.filterOptions.riskLevel.includes(riskLevel);
                });
            }
            
            // 按问题数量筛选
            if (this.filterOptions.issueCountMin !== null) {
                filtered = filtered.filter(item => 
                    item.issueCount >= this.filterOptions.issueCountMin
                );
            }
            if (this.filterOptions.issueCountMax !== null) {
                filtered = filtered.filter(item => 
                    item.issueCount <= this.filterOptions.issueCountMax
                );
            }
            
            // 按日期范围筛选
            if (this.filterOptions.dateStart) {
                filtered = filtered.filter(item => 
                    item.date >= this.filterOptions.dateStart
                );
            }
            if (this.filterOptions.dateEnd) {
                filtered = filtered.filter(item => 
                    item.date <= this.filterOptions.dateEnd
                );
            }
            
            this.searchResults = filtered;
            this.updateCharts();
            this.updateTotalItems();
        },
        // 排序相关方法
        applySorting() {
            this.showSortModal = false;
            this.sortSearchResults();
        },
        sortSearchResults() {
            if (!this.sortOption) return;
            
            const [field, order] = this.sortOption.split('-');
            
            this.searchResults.sort((a, b) => {
                let valueA, valueB;
                
                switch (field) {
                    case 'date':
                        valueA = new Date(a.date);
                        valueB = new Date(b.date);
                        break;
                    case 'issues':
                        valueA = a.issueCount;
                        valueB = b.issueCount;
                        break;
                    case 'risk':
                        const riskOrder = { '高风险': 3, '中风险': 2, '低风险': 1 };
                        valueA = riskOrder[a.riskLevel] || 0;
                        valueB = riskOrder[b.riskLevel] || 0;
                        break;
                    case 'company':
                        valueA = a.company;
                        valueB = b.company;
                        break;
                    default:
                        return 0;
                }
                
                if (order === 'asc') {
                    return valueA > valueB ? 1 : valueA < valueB ? -1 : 0;
                } else {
                    return valueA < valueB ? 1 : valueA > valueB ? -1 : 0;
                }
            });
            this.updateTotalItems();
        },
        // 更新图表
        updateCharts() {
            this.$nextTick(() => {
                this.initInspectionTypeChart();
                this.initInspectionResultChart();
                this.initInspectionTrendChart();
            });
        },
        // 导出搜索结果
        exportSearchResults() {
            try {
                // 获取当前显示的搜索结果
                const resultsToExport = this.searchResults.length > 0 ? this.searchResults : this.allSearchResults;
                
                if (resultsToExport.length === 0) {
                    ElMessage.error('没有可导出的数据！');
                    return;
                }

                // 准备导出数据
                const exportData = resultsToExport.map((item, index) => ({
                    '序号': index + 1,
                    '企业名称': item.company,
                    '巡查类型': item.type,
                    '巡查员': item.inspector,
                    '巡查日期': item.date,
                    '巡查结果': item.result,
                    '发现问题数': item.issueCount,
                    '报告状态': item.reportStatus,
                    '所属区域': item.region,
                    '企业类型': item.companyType,
                    '企业规模': item.companySize
                }));

                // 创建CSV内容
                const headers = Object.keys(exportData[0]);
                const csvContent = [
                    headers.join(','),
                    ...exportData.map(row => 
                        headers.map(header => `"${row[header] || ''}"`).join(',')
                    )
                ].join('\n');

                // 创建并下载文件
                const blob = new Blob(['\uFEFF' + csvContent], { type: 'text/csv;charset=utf-8;' });
                const link = document.createElement('a');
                const url = URL.createObjectURL(blob);
                link.setAttribute('href', url);
                link.setAttribute('download', `巡查搜索结果_${new Date().toISOString().slice(0, 10)}.csv`);
                link.style.visibility = 'hidden';
                document.body.appendChild(link);
                link.click();
                document.body.removeChild(link);

                ElMessage.success(`成功导出 ${resultsToExport.length} 条搜索结果！`);
            } catch (error) {
                ElMessage.error('导出失败，请重试！');
            }
        },
        // 查看报告
        viewReport(record) {
            // 检查报告状态
            if (record.reportStatus === '未生成') {
                ElMessage.error('该记录的报告尚未生成，请联系管理员！');
                return;
            }
            
            if (record.reportStatus === '已驳回') {
                ElMessage.error('该报告已被驳回，请联系相关人员重新生成！');
                return;
            }
            
            // 模拟报告查看功能
            const reportContent = this.generateReportContent(record);
            
            // 创建报告预览窗口
            const reportWindow = window.open('', '_blank', 'width=800,height=600,scrollbars=yes');
            reportWindow.document.write(`
                <!DOCTYPE html>
                <html>
                <head>
                    <title>${record.reportName}</title>
                    <meta charset="UTF-8">
                    <style>
                        body { font-family: Arial, sans-serif; margin: 20px; line-height: 1.6; }
                        .header { text-align: center; border-bottom: 2px solid #333; padding-bottom: 20px; margin-bottom: 30px; }
                        .section { margin-bottom: 25px; }
                        .section-title { font-size: 18px; font-weight: bold; color: #333; margin-bottom: 10px; border-left: 4px solid #007bff; padding-left: 10px; }
                        .info-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
                        .info-table td { padding: 8px; border: 1px solid #ddd; }
                        .info-table td:first-child { background-color: #f8f9fa; font-weight: bold; width: 150px; }
                        .issue-item { background-color: #fff3cd; border: 1px solid #ffeaa7; padding: 10px; margin-bottom: 10px; border-radius: 4px; }
                        .issue-title { font-weight: bold; color: #856404; }
                        .issue-desc { margin-top: 5px; color: #856404; }
                        .photos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
                        .photo { width: 150px; height: 100px; object-fit: cover; border: 1px solid #ddd; border-radius: 4px; }
                        .no-issues { color: #28a745; font-weight: bold; }
                        .print-btn { position: fixed; top: 20px; right: 20px; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; }
                        .print-btn:hover { background-color: #0056b3; }
                        @media print { .print-btn { display: none; } }
                    </style>
                </head>
                <body>
                    <button class="print-btn" onclick="window.print()">打印报告</button>
                    ${reportContent}
                </body>
                </html>
            `);
            reportWindow.document.close();
        },
        // 生成报告内容
        generateReportContent(record) {
            const issuesHtml = record.issues && record.issues.length > 0 
                ? record.issues.map(issue => `
                    <div class="issue-item">
                        <div class="issue-title">${issue.title}</div>
                        <div class="issue-desc">${issue.description}</div>
                        <div style="margin-top: 5px;">
                            <span style="color: #666;">等级: ${issue.level} | 类型: ${issue.type} | 发现时间: ${issue.foundDate} | 状态: ${issue.status}</span>
                        </div>
                    </div>
                `).join('')
                : '<div class="no-issues">本次巡查未发现安全问题</div>';
                
            const photosHtml = record.photos && record.photos.length > 0
                ? `<div class="photos">${record.photos.map(photo => `<img src="${photo.url}" alt="${photo.description}" class="photo" title="${photo.description}">`).join('')}</div>`
                : '<div style="color: #666;">暂无照片</div>';
                
            return `
                <div class="header">
                    <h1>${record.reportName}</h1>
                    <p>报告编号: ${record.id}</p>
                </div>
                
                <div class="section">
                    <div class="section-title">基本信息</div>
                    <table class="info-table">
                        <tr><td>企业名称</td><td>${record.company}</td></tr>
                        <tr><td>巡查类型</td><td>${record.type}</td></tr>
                        <tr><td>巡查人员</td><td>${record.inspector}</td></tr>
                        <tr><td>巡查日期</td><td>${record.date}</td></tr>
                        <tr><td>巡查结果</td><td>${record.result}</td></tr>
                        <tr><td>联系人</td><td>${record.contact || '未提供'}</td></tr>
                        <tr><td>联系电话</td><td>${record.phone || '未提供'}</td></tr>
                        <tr><td>报告状态</td><td>${record.reportStatus}</td></tr>
                        <tr><td>生成时间</td><td>${record.reportDate}</td></tr>
                        <tr><td>生成人员</td><td>${record.reportCreator}</td></tr>
                    </table>
                </div>
                
                <div class="section">
                    <div class="section-title">发现问题 (${record.issueCount}项)</div>
                    ${issuesHtml}
                </div>
                
                <div class="section">
                    <div class="section-title">现场照片</div>
                    ${photosHtml}
                </div>
                
                <div class="section">
                    <div class="section-title">总结建议</div>
                    <p>根据本次巡查情况，${record.company}在安全生产管理方面${record.result === '合格' ? '总体表现良好' : '存在需要改进的地方'}。${record.issueCount > 0 ? '建议企业针对发现的问题制定整改计划，确保在规定时间内完成整改。' : '希望企业继续保持良好的安全生产状态。'}</p>
                </div>
            `;
        },
        // 分页相关方法
        goToPage(page) {
            if (page >= 1 && page <= this.totalPages && page !== this.currentPage) {
                this.currentPage = page;
            }
        },
        updateTotalItems() {
            this.totalItems = this.searchResults.length;
            // 如果当前页超出范围，重置到第一页
            if (this.currentPage > this.totalPages && this.totalPages > 0) {
                this.currentPage = 1;
            }
        },
        // 导出分析报告
        exportAnalysisReport() {
            try {
                // 获取当前搜索结果数据
                const currentResults = this.searchResults.length > 0 ? this.searchResults : this.allSearchResults;
                
                if (currentResults.length === 0) {
                    ElMessage.error('没有可导出的分析数据！');
                    return;
                }

                // 生成分析数据
                const analysisData = this.generateAnalysisData(currentResults);
                
                // 生成报告内容
                const reportContent = `
检索结果分析报告

报告标题：检索结果分析报告_${new Date().toISOString().split('T')[0]}
生成时间：${new Date().toLocaleString()}

一、数据概览
• 检索记录总数：${analysisData.totalRecords} 条
• 巡查类型分布：
  - 常规巡查：${analysisData.typeStats['常规巡查']} 条
  - 专项巡查：${analysisData.typeStats['专项巡查']} 条
  - 应急巡查：${analysisData.typeStats['应急巡查']} 条

二、巡查结果统计
• 正常：${analysisData.resultStats['正常']} 条 (${analysisData.resultPercentage['正常']}%)
• 异常：${analysisData.resultStats['异常']} 条 (${analysisData.resultPercentage['异常']}%)
• 待整改：${analysisData.resultStats['待整改']} 条 (${analysisData.resultPercentage['待整改']}%)

三、问题发现情况
• 平均问题数：${analysisData.avgIssues} 个/次
• 高风险企业：${analysisData.highRiskCompanies} 家
• 中风险企业：${analysisData.mediumRiskCompanies} 家
• 低风险企业：${analysisData.lowRiskCompanies} 家

四、报告状态分析
• 已生成报告：${analysisData.reportStats['已生成']} 份
• 未生成报告：${analysisData.reportStats['未生成']} 份
• 已驳回报告：${analysisData.reportStats['已驳回']} 份

五、时间分布分析
• 数据时间范围：${analysisData.dateRange.start} 至 ${analysisData.dateRange.end}
• 巡查频率：平均每天 ${analysisData.dailyAverage} 次巡查

六、建议与改进
1. 针对高风险企业加强巡查频次
2. 提高报告生成率，减少未生成报告数量
3. 加强问题整改跟踪，提高整改效率
4. 优化巡查资源配置，提高巡查效果

七、总结
本次分析基于 ${analysisData.totalRecords} 条检索记录。
整体巡查工作开展良好，发现问题及时，建议继续保持现有工作水平并针对性改进。

报告生成时间：${new Date().toLocaleString()}
                `;

                // 创建下载链接
                const blob = new Blob([reportContent], { type: 'text/plain;charset=utf-8' });
                const url = window.URL.createObjectURL(blob);
                const link = document.createElement('a');
                link.href = url;
                link.download = `检索结果分析报告_${new Date().toISOString().split('T')[0]}.txt`;
                document.body.appendChild(link);
                link.click();
                document.body.removeChild(link);
                window.URL.revokeObjectURL(url);

                ElMessage.success(`分析报告导出成功！\n包含数据：${analysisData.totalRecords} 条记录\n导出时间：${new Date().toLocaleString()}`);
            } catch (error) {
                ElMessage.error('导出分析报告失败，请重试！');
            }
        },
        // 生成专题分析
        generateTopicAnalysis() {
            try {
                // 获取当前搜索结果数据
                const currentResults = this.searchResults.length > 0 ? this.searchResults : this.allSearchResults;
                
                if (currentResults.length === 0) {
                    ElMessage.error('没有可分析的数据！');
                    return;
                }

                // 生成专题分析数据
                const topicData = this.generateTopicAnalysisData(currentResults);
                
                // 创建专题分析页面内容
                const analysisHTML = `
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>专题分析报告</title>
    <style>
        body { font-family: 'Microsoft YaHei', sans-serif; margin: 20px; line-height: 1.6; }
        .header { text-align: center; border-bottom: 2px solid #3b82f6; padding-bottom: 20px; margin-bottom: 30px; }
        .title { font-size: 28px; font-weight: bold; color: #1f2937; margin-bottom: 10px; }
        .subtitle { font-size: 16px; color: #6b7280; }
        .section { margin-bottom: 30px; }
        .section-title { font-size: 20px; font-weight: bold; color: #3b82f6; border-left: 4px solid #3b82f6; padding-left: 10px; margin-bottom: 15px; }
        .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; }
        .stat-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px; text-align: center; }
        .stat-number { font-size: 24px; font-weight: bold; color: #3b82f6; }
        .stat-label { font-size: 14px; color: #6b7280; margin-top: 5px; }
        .recommendation { background: #fef3c7; border-left: 4px solid #f59e0b; padding: 15px; margin: 10px 0; border-radius: 4px; }
        .footer { text-align: center; margin-top: 40px; padding-top: 20px; border-top: 1px solid #e2e8f0; color: #6b7280; }
        @media print { body { margin: 0; } .no-print { display: none; } }
    </style>
</head>
<body>
    <div class="header">
        <div class="title">安全巡查专题分析报告</div>
        <div class="subtitle">基于检索结果的深度分析 | 生成时间：${new Date().toLocaleString()}</div>
    </div>

    <div class="section">
        <div class="section-title">一、数据概览</div>
        <div class="stats-grid">
            <div class="stat-card">
                <div class="stat-number">${topicData.totalRecords}</div>
                <div class="stat-label">总记录数</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">${topicData.totalCompanies}</div>
                <div class="stat-label">涉及企业</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">${topicData.totalIssues}</div>
                <div class="stat-label">发现问题</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">${topicData.avgIssuesPerInspection}</div>
                <div class="stat-label">平均问题数/次</div>
            </div>
        </div>
    </div>

    <div class="section">
        <div class="section-title">二、巡查类型分析</div>
        <div class="stats-grid">
            <div class="stat-card">
                <div class="stat-number">${topicData.typeStats['常规巡查']}</div>
                <div class="stat-label">常规巡查 (${topicData.typePercentage['常规巡查']}%)</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">${topicData.typeStats['专项巡查']}</div>
                <div class="stat-label">专项巡查 (${topicData.typePercentage['专项巡查']}%)</div>
            </div>
            <div class="stat-card">
                <div class="stat-number">${topicData.typeStats['应急巡查']}</div>
                <div class="stat-label">应急巡查 (${topicData.typePercentage['应急巡查']}%)</div>
            </div>
        </div>
    </div>

    <div class="section">
        <div class="section-title">三、风险等级分析</div>
        <div class="stats-grid">
            <div class="stat-card">
                <div class="stat-number" style="color: #dc2626;">${topicData.riskStats['高风险']}</div>
                <div class="stat-label">高风险企业</div>
            </div>
            <div class="stat-card">
                <div class="stat-number" style="color: #f59e0b;">${topicData.riskStats['中风险']}</div>
                <div class="stat-label">中风险企业</div>
            </div>
            <div class="stat-card">
                <div class="stat-number" style="color: #10b981;">${topicData.riskStats['低风险']}</div>
                <div class="stat-label">低风险企业</div>
            </div>
        </div>
    </div>

    <div class="section">
        <div class="section-title">四、问题发现趋势</div>
        <p>分析期间共发现 ${topicData.totalIssues} 个问题，平均每次巡查发现 ${topicData.avgIssuesPerInspection} 个问题。</p>
    </div>

    <div class="section">
        <div class="section-title">五、重点关注企业</div>
        ${topicData.highRiskCompanies.map(company => `
            <div class="recommendation">
                <strong>${company.name}</strong> - 发现问题 ${company.issues} 个，建议加强监管
            </div>
        `).join('')}
    </div>

    <div class="section">
        <div class="section-title">六、改进建议</div>
        <div class="recommendation">
            <strong>1. 巡查频次优化：</strong>对高风险企业增加巡查频次，建议从当前频次提升30%
        </div>
        <div class="recommendation">
            <strong>2. 问题整改跟踪：</strong>建立问题整改台账，确保问题闭环管理
        </div>
        <div class="recommendation">
            <strong>3. 预防性措施：</strong>针对高频问题制定预防性措施和标准化流程
        </div>
        <div class="recommendation">
            <strong>4. 人员培训：</strong>加强巡查人员专业技能培训，提高问题识别能力
        </div>
    </div>

    <div class="footer">
        <p>本报告基于 ${topicData.totalRecords} 条巡查记录生成</p>
        <p>报告生成时间：${new Date().toLocaleString()}</p>
        <p class="no-print">
            <button onclick="window.print()" style="background: #3b82f6; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer;">打印报告</button>
        </p>
    </div>
</body>
</html>
                `;

                // 在新窗口中打开专题分析
                const newWindow = window.open('', '_blank');
                newWindow.document.write(analysisHTML);
                newWindow.document.close();

                ElMessage.success(`专题分析生成成功！\n分析数据：${topicData.totalRecords} 条记录\n涉及企业：${topicData.totalCompanies} 家\n发现问题：${topicData.totalIssues} 个`);
            } catch (error) {
                ElMessage.error('生成专题分析失败，请重试！');
            }
        },
        // 生成分析数据
        generateAnalysisData(results) {
            const typeStats = { '常规巡查': 0, '专项巡查': 0, '应急巡查': 0 };
            const resultStats = { '正常': 0, '异常': 0, '待整改': 0 };
            const reportStats = { '已生成': 0, '未生成': 0, '已驳回': 0 };
            let totalIssues = 0;
            let highRiskCount = 0, mediumRiskCount = 0, lowRiskCount = 0;
            const dates = [];

            results.forEach(item => {
                // 统计巡查类型
                typeStats[item.type] = (typeStats[item.type] || 0) + 1;
                
                // 统计巡查结果
                resultStats[item.result] = (resultStats[item.result] || 0) + 1;
                
                // 统计报告状态
                reportStats[item.reportStatus] = (reportStats[item.reportStatus] || 0) + 1;
                
                // 统计问题数
                totalIssues += item.issueCount;
                
                // 统计风险等级
                if (item.issueCount >= 8) highRiskCount++;
                else if (item.issueCount >= 4) mediumRiskCount++;
                else lowRiskCount++;
                
                // 收集日期
                dates.push(item.date);
            });

            // 计算百分比
            const total = results.length;
            const resultPercentage = {};
            Object.keys(resultStats).forEach(key => {
                resultPercentage[key] = ((resultStats[key] / total) * 100).toFixed(1);
            });

            // 计算日期范围
            const sortedDates = dates.sort();
            const dateRange = {
                start: sortedDates[0] || '',
                end: sortedDates[sortedDates.length - 1] || ''
            };

            // 计算日均巡查次数
            const daysDiff = dateRange.start && dateRange.end ? 
                Math.max(1, Math.ceil((new Date(dateRange.end) - new Date(dateRange.start)) / (1000 * 60 * 60 * 24))) : 1;
            const dailyAverage = (total / daysDiff).toFixed(1);

            return {
                totalRecords: total,
                typeStats,
                resultStats,
                resultPercentage,
                reportStats,
                avgIssues: (totalIssues / total).toFixed(1),
                highRiskCompanies: highRiskCount,
                mediumRiskCompanies: mediumRiskCount,
                lowRiskCompanies: lowRiskCount,
                dateRange,
                dailyAverage
            };
        },
        // 生成专题分析数据
        generateTopicAnalysisData(results) {
            const typeStats = { '常规巡查': 0, '专项巡查': 0, '应急巡查': 0 };
            const riskStats = { '高风险': 0, '中风险': 0, '低风险': 0 };
            const companies = new Set();
            let totalIssues = 0;
            const companyIssues = {};

            results.forEach(item => {
                // 统计巡查类型
                typeStats[item.type] = (typeStats[item.type] || 0) + 1;
                
                // 统计企业
                companies.add(item.company);
                
                // 统计问题数
                totalIssues += item.issueCount;
                
                // 统计企业问题数
                companyIssues[item.company] = (companyIssues[item.company] || 0) + item.issueCount;
                
                // 统计风险等级
                if (item.issueCount >= 8) riskStats['高风险']++;
                else if (item.issueCount >= 4) riskStats['中风险']++;
                else riskStats['低风险']++;
            });

            // 计算百分比
            const total = results.length;
            const typePercentage = {};
            Object.keys(typeStats).forEach(key => {
                typePercentage[key] = ((typeStats[key] / total) * 100).toFixed(1);
            });

            // 获取高风险企业列表
            const highRiskCompanies = Object.entries(companyIssues)
                .filter(([company, issues]) => issues >= 8)
                .map(([company, issues]) => ({ name: company, issues }))
                .sort((a, b) => b.issues - a.issues)
                .slice(0, 5); // 取前5家

            return {
                totalRecords: total,
                totalCompanies: companies.size,
                totalIssues,
                avgIssuesPerInspection: (totalIssues / total).toFixed(1),
                typeStats,
                typePercentage,
                riskStats,
                highRiskCompanies
            };
        }
    }
};
</script>
<style scoped>
/* 隐藏input number的箭头 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}
</style>